Is there any way using reflection in C# 3.5 to determine if type of an object List<MyObject>?
For example here:
Type type = customerList.GetType();
//what should I do with type here to determine if customerList is List<Customer> ?
Thanks.
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.
To add to Lucas’s response, you’ll probably want to be a little defensive by making sure that you do in fact have
List<something>:Edit: The above code says, ‘what kind of list is it?’. To answer ‘is this a
List<MyObject>?‘, use theisoperator as normal:Or, if all you have is a
Type: