Monday, October 1, 2007

.net generics tips

You can get the type of a generic collection by doing:

Type t = typeof(IList<>).MakeGenericType(T)


You can also constrict a type parameter to require a public constructor by adding ', new()'

No comments: