Generic type definition syntax on F#

非 Y 不嫁゛ 提交于 2019-12-12 10:37:26

问题


This is not a big deal, but is there any way in F# to get a generic type definition without calling GetGenericTypeDefinition() ? IComparable<_> is IComparable<object> (or whatever type is inferred) and IComparable<> is a syntax error.

VB.NET

GetType(IComparable(Of ))

C#

typeof(IComparable<>)

F#

typeof<IComparable<_>>.GetGenericTypeDefinition()

回答1:


You want "typedefof"

printfn "%s" (typedefof<list<int>>).Name


来源:https://stackoverflow.com/questions/1652050/generic-type-definition-syntax-on-f

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!