C#

Lazy Sequences With yield in C#

C#Iteratorsyieldadvanced

yield return builds a state machine that produces values on demand, so an infinite sequence is safe as long as it is bounded by the consumer.

expected output

0,1,1,2,3,5,8

Why practise typing this

Typing iterators code builds muscle memory for the symbols and indentation C# uses most, which prose-based typing tests never cover. DevType measures your words per minute and accuracy on this snippet and tracks the individual characters you mistype, so later lessons can target them.

More C# practice

Browse all C# snippets →