Deferred execution and eager evaluation

后端 未结 2 1849
误落风尘
误落风尘 2020-11-27 11:52

Could you please give me an example for Deferred execution with eager evaluation in C#?

I read from MSDN that deferred execution in LINQ can be implemented either wi

2条回答
  •  爱一瞬间的悲伤
    2020-11-27 12:42

    One way that you could eagerly evaluate a deferred execution IEnumerable is to simply turn it into an array using linq's .ToArray() function.

    var evaluated = enumerable.ToArray();
    

    This forces evaluation of the full enumerable and then you have the array that you can do whatever you want with.

提交回复
热议问题