Last active
June 26, 2020 20:04
-
-
Save JohnMGant/6a25cf3074185a43dfff455eb26728cb to your computer and use it in GitHub Desktop.
Adds an array of integers using a for loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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