I saw code like below. My questions are:
1> ()=>Name what does this mean?
2> Is Expression<Func<>> the same as Expression<TDelegate>? How is ()=>Name cast to Expression<Func<>> and which constructor is used? Most Expression classes don't have public constructors. How does C# compiler convert from Lambda to Expression?
3> What is the performance cost of the Parse function?
public class Test
{
public string Name {get;set;}
public void Start()
{
Parse(()=>Name);
}
public string Parse<T>(Expression<Func<T>> exp)
{
var mexp = (System.Linq.Expressions.MemberExpression)expression.Body;
return mexp == null ? "" : mexp.Member.Name;
}
}