我想在运行时检查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
}
Run Code Online (Sandbox Code Playgroud)
您应该能够直接使用==以下两者进行比较:
if (myFunc == Foo.MyMethod) { ... }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
130 次 |
| 最近记录: |