lambda expression based reflection vs normal reflection

Posted by bitbonk on Stack Overflow See other posts from Stack Overflow or by bitbonk
Published on 2010-04-23T10:00:00Z Indexed on 2010/04/23 10:03 UTC
Read the original article Hit count: 697

What is the difference between normal reflection and the reflection that can be done with lambda expressions such as this (taken form build your own MVVM):

public void NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>> property)
{
    var lambda = (LambdaExpression)property;
    MemberExpression memberExpression;
    if (lambda.Body is UnaryExpression)
    {
        var unaryExpression = (UnaryExpression)lambda.Body;
        memberExpression = (MemberExpression)unaryExpression.Operand;
    }
    else memberExpression = (MemberExpression)lambda.Body;
    NotifyOfPropertyChange(memberExpression.Member.Name);
 }

Is the lambda based reflection just using the normal reflection APIs internally? Or is this something significantly different. What is ther perfomance difference?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about refelection