Read Program.cs first, then run it: dotnet run --project reps/02. It prints:
for: 3,3,3
foreach: 0,1,2
Most readers expect 0,1,2 twice; some, burned once, expect 3,3,3 twice.
Read Program.cs first, then run it: dotnet run --project reps/02. It prints:
for: 3,3,3
foreach: 0,1,2
Most readers expect 0,1,2 twice; some, burned once, expect 3,3,3 twice.
i variables do the two loops create, and how many n? Answer that and both lines follow.
foreach hasn't always behaved like this. When did it change, and what does that mean for code written before then?