Reputation: 3531
How can I instantiate a generic type definition in F#? (i.e. an instance of Type class whose IsGenericTypeDefinition property returns true).
Example in C#:
Type d1 = typeof(Dictionary<,>);
Note:
typeof<Dictionary<'T,'U>>
does not work. 'T and 'U are interpreted as object.
Upvotes: 2
Views: 140
Reputation: 10624
let t = typedefof<Dictionary<_,_>>
t.IsGenericTypeDefinition // true
This is not the same as typeof
. Note the def
in the middle :)
Upvotes: 3