Given:
public T Get<T>() { ... }
where T is closed to IEnumerable<XYZ>, how can I determine the XYZ type?
I have no variable to start with.
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.
You can use the TypeSystem.GetElementType Method from LINQ: Building an IQueryable Provider – Part I to get
typeof(XYZ)when giventypeof(IEnumerable<XYZ>):In your method, you can use
typeof(T)to get the Type object that representsT.