[英]ConstructorInfo of a function/delegate in F#
如何在 F# 中获得以下 CIL 构造函数(作为System.Relection.ConstructorInfo
)?
[mscorlib]System.Func`3<int32,int32,int32>::.ctor(object, native int)
我尝试了以下方法,但得到 null:
typeof<int * int * int>.GetConstructor([|typeof<obj> ; typeof<nativeint>|]);;
val it : System.Reflection.ConstructorInfo = <null>
另外,是否可以动态执行? 假设不是 3 种 int 类型,而是随机的System.Type list
。 如何?
发现:
System.Linq.Expressions.Expression.GetDelegateType([|typeof<int> ; typeof<int> ; typeof<int>|]).GetConstructor([|typeof<obj> ; typeof<nativeint>|]).DeclaringType;;
GetDelegateType
方法采用类型数组,因此可以动态使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.