Odd or Even ? Programming exercise.

Given an array of numbers, determine whether the sum of its elements is odd or even.

This is a small task, but as they say repetition is mother of learning. I don’t know is it true or not, but do a good job and you may have a cookie.

There is a solution hiding in the page. Do not scroll down!

    public static string OddOrEven(int[] array)
    {
//Lets see.. first we need some memory for the summing        
        int sum = 0;
//then we shall go through each item in the array
        foreach (var item in array)
        {
            sum += item; //and sum the numbers
        }
//this % gives what remain after the division of the two items
//so sum%2 will divide sum/2 and return the reminder
//if there is no remainder after the division 
        if (sum % 2 == 0) return "even"; //the sum is even
        else return "odd"; //else its odd
    }