Skip to content

Instantly share code, notes, and snippets.

@JohnMGant
Last active June 26, 2020 20:04
Show Gist options
  • Select an option

  • Save JohnMGant/6a25cf3074185a43dfff455eb26728cb to your computer and use it in GitHub Desktop.

Select an option

Save JohnMGant/6a25cf3074185a43dfff455eb26728cb to your computer and use it in GitHub Desktop.
Adds an array of integers using a for loop
internal class ForLoopAdder : IIntegerAdder
{
public int Add(int[] values)
{
int sum = 0;
int count = values.Length;
for (int i = 0; i < count; i++)
{
int value = values[i];
sum += value;
}
return sum;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment