Skip to content

Instantly share code, notes, and snippets.

@Lokno
Last active July 2, 2025 13:19
Show Gist options
  • Save Lokno/c30fcf94fd1392baf60c2099a2b18ba5 to your computer and use it in GitHub Desktop.
Save Lokno/c30fcf94fd1392baf60c2099a2b18ba5 to your computer and use it in GitHub Desktop.
Demonstration of intentional overflow loop and infinite loop pitfall
byte id = 25;
int temp;
Console.WriteLine($"Loop Start!");
//for(byte i = (byte)(id+1); i <= byte.MaxValue; i++ ) // infinite loop
for(byte i = (byte)(id+1); i != id; i++ )
{
Console.WriteLine($"i: {i}");
temp = i;
}
Console.WriteLine($"Loop Ended!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment