int variable = sentence.lenght won't work but sentence.Lenght will (c#) : I'm an absolute beginner in c#,I'll have my first exam in a week or so and I just can't understand this.
I know it's easier the 2nd way, but I just want to understand why the first won't work.
The objective of the code is to remove the positions where there are 2+ spaces together, and replace them with a single space.

    static void Main(string[] args)
        {
            string sentence = Console.ReadLine();
            int size = Convert.ToInt16(sentence.Length);

            for (int i = 0; i < size - 1; i++)
            {
                sentence = sentence.Trim();
                while ((sentence[i] == ' ' ) && (sentence[i+1] == ' '))
                {
                    sentence = sentence.Remove(i + 1, 1);
                }
            }

            Console.WriteLine(sentence);
            Console.ReadLine();
        }

for some reason this code won't work if you throw 2 or more spaces.
But this one works, if you use sentence.lenght , instead of size variable above.

    static void Main(string[] args)
        {
            string sentence = Convert.ToString(Console.ReadLine());
            for (int i = 0; i < sentence.Length - 1; i++)
            {
                while ((sentence[i] == ' ') && (sentence[i + 1] == ' '))
                {
                    sentence = sentence.Remove(i + 1, 1);
                }
            }
            Console.WriteLine("Sentence:{0}", sentence);
            Console.ReadLine();
        }

Sorry if it sounds like a stupid question, but me and my class can't find why the 1st one won't work.
Thanks for reading!