After reading this related answer -still I have a question
A lambda expression is an unnamed method written in place of a delegate instance. The compiler immediately converts the lambda expression to either:
- A delegate instance.
- An expression tree, of type Expression, representing the code inside the lambda expression in a traversable object model.
But When will it convert it do a delegate instance -- and when when it will convert it to expression tree ? ( didn't find related info on that one)
Not much of a related code - just tried to played with it - obviously both a matching. I didn't think so because I thought one would be a better match .
void Main()
{
Foo( () => 0 );
}
void Foo(Func<int > action)
{
Console.WriteLine("1");
}
void Foo(Expression<Func<int>> func)
{
Console.WriteLine("2");
}
This will result in error (ambiguous between the following methods or properties)