Reflections
-
How to get the values of some properties in the class Like I have a Class ... Class1 in which some properties are defined say FName, LName.. What I want is that I want to apply this thing to many classes of which I don't know the properties that it contains as in.... in class1 it may be FName or LName but what is in class 2 I don't know I want to have some common code that will apply for all the classes I want. the problem with this one is that here I have to call the values of all the properties individually How can I do this? Please reply. Thanks in Advance Parag Gupta
-
How to get the values of some properties in the class Like I have a Class ... Class1 in which some properties are defined say FName, LName.. What I want is that I want to apply this thing to many classes of which I don't know the properties that it contains as in.... in class1 it may be FName or LName but what is in class 2 I don't know I want to have some common code that will apply for all the classes I want. the problem with this one is that here I have to call the values of all the properties individually How can I do this? Please reply. Thanks in Advance Parag Gupta
Hello I don't think I fully understand your question, but if you want to browse through all properties of a certain type -not instance- and get their names then call
Type.GetProperties()
method. If you have a certain object of that type, and you want to check the value of that property, then get thePropertyInfo
and callPropertyInfo.GetValue()
method supplying it with the object you want to check for that value. I hope this was helpful.Regards:rose: