如何解决F#
如何在F#中获得以下CIL构造函数(如System.Relection.ConstructorInfo
)?
[mscorlib]System.Func`3<int32,int32,int32>::.ctor(object,native int)
我尝试了以下操作,但没有得到结果:
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
方法采用类型数组,因此可以动态使用。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。