问题
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