我想在运行时检查Func 类型的变量是特定的类方法。
例如。
class Foo
{
public static int MyMethod(int a, int b)
{
//...
}
}
Func<int, int, int> myFunc;
myFunc = Foo.MyMethod;
if(myFunc is Foo.MyMethod)
{
//do something
}
最佳答案
您应该能够使用==
直接比较两者:
if (myFunc == Foo.MyMethod) { ... }
关于c# - 如何检查Func <...>类型的变量是否为特定的类方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26851192/