Deferred execution in C#

前端 未结 6 2059
无人共我
无人共我 2021-01-04 07:36

How could I implement my own deferred execution mechanism in C#?

So for instance I have:

string x = DoFoo();

Is it possible to perf

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 07:46

    You pretty much describe LINQ in action. A linq query describes how to obtain the data, but data is retrieved (DoFunc is called) only when the query is iterated. Consider if you can change your design to accept IQueryable where you need a string.

提交回复
热议问题