You are viewing a single comment's thread from:

RE: What the hell does C# yield do?

in #programming9 years ago

Yep, it gets complex. The key to it is that you avoid mutation of any state and there is 0 risk. If you have mutation then the problem is you have no idea when code will run and hence when the mutation will take place.

In C# you can force evaluation early

var oldPeople = people.Where(persion => person.Age >= 65).ToArray();

The ToArray() forces all the code to execute there and then, removes the lazy state

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.098
BTC 64222.97
ETH 1872.99
USDT 1.00
SBD 0.38