Loop invariant - C#