Capital Position programming exercise

Capital Position programming exercise.

The uppercase letters from the capital are infiltrating the array. Quick help the array by:

Writing a function that takes a string as an argument and returns an integer array in which is captured the position (starting from 0) of every capital (uppercase) letters.

Example:
input: "aBcdE"
output: 1,4

This is a small an relaxing coding problem. Scroll down for its solution.

    public static int[] TakeCapitalPosition(string word)
    {
        //first we need some memory for the result
        //I am going to use a list of integers for that
        List<int> r = new List<int>();
        //then we are going to go through every character
        //in the string and if the char IsUpper
        //add it to the list
        for (int i = 0; i < word.Length; i++)
        {
            if (Char.IsUpper(word[i]))
            {
                r.Add(i);
            }
        }            
        //the return the result in form of an array.
        return r.ToArray();
    }