我想在运行时检查 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/