Is it a way to discover, at the run time, the name of a property of an object?
In other words is it possible to create a method GetPropertyName , that takes
a property of an object and returns the name of that property? So:
string name = GetPropertyName (int.MaxValue); // returns “MaxValueâ€
string name = GetPropertyName (DateTime.Now); // returns “Nowâ€
(Something similar exists to
System.Reflecti on.MethodInfo.G etCurrentMethod ().Name; that returns the name
of the current method)
In other words is it possible to create a method GetPropertyName , that takes
a property of an object and returns the name of that property? So:
string name = GetPropertyName (int.MaxValue); // returns “MaxValueâ€
string name = GetPropertyName (DateTime.Now); // returns “Nowâ€
(Something similar exists to
System.Reflecti on.MethodInfo.G etCurrentMethod ().Name; that returns the name
of the current method)
Comment