is there a way to retrieve type T from IEnumerable<T> through reflection?
e.g.
i have a variable IEnumerable<Child> info; i want to retrieve Child’s type through reflection
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Thusly,
prints
System.String.See MSDN for
Type.GetGenericArguments.Edit: I believe this will address the concerns in the comments:
Some objects implement more than one generic
IEnumerableso it is necessary to return an enumeration of them.Edit: Although, I have to say, it’s a terrible idea for a class to implement
IEnumerable<T>for more than oneT.