Continuing examining new types in Whidbey…  My goal is to motivate why we added Whidbey features through simple little quizzes.   For today, let’s say you have several arrays of ints and you want to sum different sub ranges from each one (that is, a different start index and count for each array).  For example, if you start at zero for a count of 1 for every array the sum will be 8.  Write the Sum() method called below. 

 

    int[] set1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

    int[] set2 = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };

    int[] set3 = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 };

    int[] set4 = { 1, 1, 2, 3, 5, 8, 13, 21 };

    int[] set5 = { 2, 3, 5, 7, 11, 13, 17, 19 };

    int[] set1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

 

    int sum = Sum(/* need to pass the all the sets above, start indices and counts for each */);

           

     Console.WriteLine("sum = {0}",sum);