yield
for Lazy Evaluationyield
for Lazy EvaluationUse yield
to create generators that can be used in foreach
loops. yield
is a memory-efficient alternative to arrays, as it only generates values when needed, unlike arrays, which are stored in memory.