F# F上的泛型类型定义语法#
这没什么大不了的,但是在F#中有没有办法不调用GetGenericTypeDefinition()而获得泛型类型定义F# F上的泛型类型定义语法#,f#,F#,这没什么大不了的,但是在F#中有没有办法不调用GetGenericTypeDefinition()而获得泛型类型定义IComparable是IComparable(或推断出的任何类型),而IComparable是语法错误 VB.NET GetType(IComparable(Of )) C# typeof(i可比较) F# typeof.GetGenericTypeDefinition() 您想要“typedefof” printfn“%s”(typedefof).Name 请注意,在极少数
IComparable
是IComparable
(或推断出的任何类型),而IComparable
是语法错误
VB.NET
GetType(IComparable(Of ))
C#
typeof(i可比较)
F#
typeof.GetGenericTypeDefinition()
您想要“typedefof”
printfn“%s”(typedefof).Name
请注意,在极少数情况下,您需要将其用作属性的System.Type参数,这是“一件大事”。“[]”显然是不允许的。希望我的博客就是我的博客!
typeof(IComparable<>)
typeof<IComparable<_>>.GetGenericTypeDefinition()
printfn "%s" (typedefof<list<int>>).Name