Is there a simple way to get the underlying type of a generic collection using reflection? For example, if I have an IList<T>, how do I find out the type of T? The best I have been able to do so far is:
myProperty.PropertyType.UnderlyingSystemType.ToString() |
That gives me a string like this
:
"System.Collections.Generic.IList`1[Fsm.Core.Domain.Category]" |
I can then parse that string to get the underlying type ('Category' in this case).
The parsing code is an ugly hack--is there a simpler, more direct way to get the type of class T? Thanks for your help.
David Veeneman
Foresight Systems