Possible Duplicate:
Reflection - Getting the generic parameters from a System.Type instance
Get actual type of T in a generic List<T>
I'm looping through a PropertyInfo-List from a Class.
In this class, I'm interested in the different Lists - for example List<int>, List<string>, List<Book>, aso.
But I don't know how I get the Type of the List-Objects. I just get something like
System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]].
I could take this information apart and create a Type out of this information, but I hope there's a smoother way?
Simple:
Type type = list.GetType().GetGenericArguments()[0];
// The first argument will be the `T` inside `List<T>`... so the list type ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With