How yield implements the pattern of lazy loading?
问题 How yield implements the pattern of lazy loading ? 回答1: yield implementation doesn't reach the code until it's needed. For example, this code: public IEnumerable<int> GetInts() { yield return 1; yield return 2; yield return 3; } Will actually compile into a nested class which implements IEnumerable<int> and the body of GetInts() will return an instance of that class. Using reflector you can see: public IEnumerable<int> GetInts() { <GetInts>d__6d d__d = new <GetInts>d__6d(-2); d__d.<>4__this =