Apollo 13 - Tao Liu's blog
Failure is not an option.
Pages
Home
Topics
About
Wednesday, August 31, 2011
Create generic type using F#
you can use typeof operator to get a concrete type, just like C#'s typeof operator. But when thing comes to the generic type, it becomes different.
in C#, you can do: typeof(List<>), but in F#, if you do typeof
> you will get List
type. The solution is simple: you have to use typedefof
>,this will give a generic type definition and you can use GenerateGenericType to create the concrete type. In summary:
typeof
: for get concrete type
typedefof
: get the generic type definition.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment