A while ago I needed a way to pass a property (i.e. not its value but the actual property) to a method. I can't remember the reason why but I thought it was great how C# allowed this with reflection and lambda expressions. I couldn't remember the context so in the below example is used to get description attribute off a property. This is probably the worst way to get a description off a property, its just to illustrate passing a property.
The method that accepts a property looks like below:
And you can pass a property to it with the following:
A sample program that grabs the description off a property would look like this:
At the moment the GetPropertyInfo<T1, T>(Expression<Func<T1>> expression, T2 parentClass) method requires the parent class to be passed in but there may be a way to get it from the expression parameter.