Skip to content

Instantly share code, notes, and snippets.

@JohnMGant
Last active December 16, 2020 22:38
Show Gist options
  • Select an option

  • Save JohnMGant/406103d589a46f68711ec9c07fe8edb6 to your computer and use it in GitHub Desktop.

Select an option

Save JohnMGant/406103d589a46f68711ec9c07fe8edb6 to your computer and use it in GitHub Desktop.
Adds an array of integers using goto (don't do this!)
internal class GotoAdder : IIntegerAdder
{
public int Add(int[] values)
{
int sum = 0;
int count = values.Length;
int index = 0;
BEGIN:
if (index == count) goto RETURN;
int value = values[index++];
sum += value;
goto BEGIN;
RETURN:
return sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment