How does the following LINQ statement work?

后端 未结 5 1150
南旧
南旧 2021-01-29 22:24

How does the following LINQ statement work?

Here is my code:

var list = new List{1,2,4,5,6};
var even = list.Where(m => m%2 == 0);
list.Add         


        
5条回答
  •  醉话见心
    2021-01-29 22:42

    The reason for this is the deferred execution of your lambda expression. The query gets executed when you start iterating in the foreach loop.

提交回复
热议问题