Problem with "33 Code Project" (Chapter: Methods) / C#-Tutorial
Hey there! :-) I recently tried to solve "33 Code Project" (Chapter: Methods) while working on the C#-tutorial. Here's my solution: ------------------------------------------------------------------------------ using System; using System.Collections.Generic; namespace SoloLearn { class Program { static void Main(string[] args) { int levels = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Points(levels)); Console.ReadLine(); } static int Points(int anzahlLevel) { int[] myArray = new int[anzahlLevel]; int arrayIndex = 0; while (arrayIndex < anzahlLevel) { myArray[arrayIndex] = ++arrayIndex; } int sumLevel = myArray.Sum(); return sumLevel; } } } ------------------------------------------------------------------------------ I always tried to solve the exercises "my way" and it has never been a problem before. This time I got the following error message: "usercode/file0.cs(27,36): error CS1061: 'int[]' does not contain a definition for 'Sum' and no accessible extension method 'Sum' accepting a first argument of type 'int[]' could be found (are you missing a using directive or an assembly reference?)" My code worked just fine in Visual Studio and the output was correct, too. Could you please tell me what I did wrong? :-/ Thanks in advance! ^-^