Difference in CSC and Roslyn compiler's static lambda expression evaluation?

前端 未结 1 1647
挽巷
挽巷 2020-12-11 18:14

Consider the following example code.

class Program
{
    static void Main( string[] args )
    {
        DoSomethingWithAction( i =>
            {
                


        
1条回答
  •  囚心锁ツ
    2020-12-11 18:55

    This was a deliberate change made by the Roslyn team.

    Delegates that point to instance methods are slightly faster to invoke, so Roslyn now compiles lambdas to instance methods even when it doesn't need to.

    See discussion.

    0 讨论(0)
提交回复
热议问题