I know how to get an object properties using reflection:
var properties = typeof(T).GetProperties();
now how do I know if properties[0] is a string? or maybe it is a int? how can I know?
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.
Each element of
propertieswill be aPropertyInfo, which has aPropertyTypeproperty, indicating the type of the property.So for example, you might use:
or if you wanted to check something in an inheritance-permitting way: