What is the yield keyword used for in C#?
yield is a contextual keyword used in iterator methods in C#. Basically, it has two use cases:
yield return obj;returns the next item in the sequence.
yield break;stops returning sequence elements (this happens automatically if control reaches the end of the iterator method body).