C# 如何检测函数指针类型?
是否有方法检测字段的函数指针类型 C#9编译器接受以下代码:C# 如何检测函数指针类型?,c#,function-pointers,C#,Function Pointers,是否有方法检测字段的函数指针类型 C#9编译器接受以下代码: unsafe class Foo { public delegate*<string, int> functionPointer = &GetLength; static int GetLength(string s) => s.Length; } 不安全类Foo { 公共委托*functionPointer=&GetLength; 静态int GetLength(字符串s)=
unsafe class Foo
{
public delegate*<string, int> functionPointer = &GetLength;
static int GetLength(string s) => s.Length;
}
不安全类Foo
{
公共委托*functionPointer=&GetLength;
静态int GetLength(字符串s)=>s.Length;
}
到目前为止,我通过反射发现:
- 字段类型为
IntPtr
- 没有自定义属性应用于字段
- 没有对字段应用自定义修改器