<p>I am trying to write a function that will pull the name of a property and the type using syntax like below:</p>

<pre><code>private class SomeClass
{
    Public string Col1;
}

PropertyMapper&lt;Somewhere&gt; propertyMapper = new PropertyMapper&lt;Somewhere&gt;();
propertyMapper.MapProperty(x =&gt; x.Col1)
</code></pre>

<p>Is there any way to pass the property through to the function without any major changes to this syntax?</p>

<p>I would like to get the property name and the property type.</p>

<p>So in the example below i would want to retrieve </p>

<p><code>Name = "Col1"</code> and <code>Type = "System.String"</code></p>

<p>Can anyone help?</p>

Here's enough of an example of using
Expressions
to get the name of a property or field to get you started:
```
```
public static MemberInfo GetMemberInfo<T, U>(Expression<Func<T, U>> expression)
{
    var member = expression.Body as MemberExpression;
    if (member != null)
        return member.Member;

    throw new ArgumentException("Expression is not a member access", "expression");
}
```
```
Calling code would look like this:
```
```
public class Program
{
    public string Name
    {
        get { return "My Program"; }
    }

    static void Main()
    {
        MemberInfo member = ReflectionUtility.GetMemberInfo((Program p) => p.Name);
        Console.WriteLine(member.Name);
    }
}
```
```
A word of caution, though: the simple statment of
```
(Program p) => p.Name
```
actually involves quite a bit of work (and can take measurable amounts of time). Consider caching the result rather than calling the method frequently.