diff --git a/nice-project/ImportantStuff.cs b/nice-project/ImportantStuff.cs index 1c77ade..e945038 100644 --- a/nice-project/ImportantStuff.cs +++ b/nice-project/ImportantStuff.cs @@ -16,13 +16,7 @@ public int DoWhatNeedsToBeDone(IFileReader fileReader) private int CalculateSumOf(IEnumerable allNumbers) { - var sum = 0; - foreach (var number in allNumbers) - { - sum += number; - } - - return sum; + return allNumbers.Sum(); } } } \ No newline at end of file diff --git a/nice-project/Program.cs b/nice-project/Program.cs index 0f4c8c4..f3873a9 100644 --- a/nice-project/Program.cs +++ b/nice-project/Program.cs @@ -14,6 +14,9 @@ static void Main(string[] args) var result = stuff.DoWhatNeedsToBeDone(fileReader); Console.WriteLine($"Result is {result}"); + + // Wait for input + Console.ReadLine(); } } } \ No newline at end of file diff --git a/nice-project/SomeStrangeFileReader.cs b/nice-project/SomeStrangeFileReader.cs new file mode 100644 index 0000000..30cfa05 --- /dev/null +++ b/nice-project/SomeStrangeFileReader.cs @@ -0,0 +1,21 @@ +namespace NiceProject +{ + using System.Collections.Generic; + using System.IO; + + public class SomeStrangeFileReader : IFileReader + { + private string path; + + public SomeStrangeFileReader(string path) + { + this.path = path; + } + + public IEnumerable ReadAllNumbers() + { + FileInfo fi = new FileInfo(path); + yield return (int) fi.Length; + } + } +} \ No newline at end of file