reflection - Know the types of properties in an object c# -


i know how object properties using reflection:

var properties = typeof(t).getproperties(); 

now how know if properties[0] string? or maybe int? how can know?

each element of properties propertyinfo, has propertytype property, indicating type of property.

so example, might use:

if (properties[0].propertytype == typeof(string)) 

or if wanted check in inheritance-permitting way:

if (typeof(stream).isassignablefrom(properties[0].propertytype)) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -