T tolisss Jan 29, 2005 #1 Hi is it possible to get a property name like someMethod(someClass.SomeProperty)=="SomeProperty"
J Jon Skeet [C# MVP] Jan 30, 2005 #2 tolisss said: Hi is it possible to get a property name like someMethod(someClass.SomeProperty)=="SomeProperty" Click to expand... No. someClass.SomeProperty would always be treated as an expression, and evaluated rather than treated just as a name.
tolisss said: Hi is it possible to get a property name like someMethod(someClass.SomeProperty)=="SomeProperty" Click to expand... No. someClass.SomeProperty would always be treated as an expression, and evaluated rather than treated just as a name.
L Lionel LASKE Jan 30, 2005 #3 Another solution: Try Type.GetProperties() to retrieve all properties for a class and iterate to find your property. myPropertyInfo = Type.GetType("someClass").GetProperties(); for(int i=0;i<myPropertyInfo.Length;i++) { PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo; Console.WriteLine("The property name is {0}.", myPropInfo.Name); Console.WriteLine("The property type is {0}.", myPropInfo.PropertyType); } I hope it helps. Lionel.
Another solution: Try Type.GetProperties() to retrieve all properties for a class and iterate to find your property. myPropertyInfo = Type.GetType("someClass").GetProperties(); for(int i=0;i<myPropertyInfo.Length;i++) { PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo; Console.WriteLine("The property name is {0}.", myPropInfo.Name); Console.WriteLine("The property type is {0}.", myPropInfo.PropertyType); } I hope it helps. Lionel.