Using ToUpper method

Hi, if we want to have user’s answer all uppercase, why this works

Console.Write("YES or NO: ");
string noiseChoice = Console.ReadLine();

and this does not

Console.Write("YES or NO: ");
string noiseChoice.ToUpper() = Console.ReadLine();

You are saying change noiseChange to upper case before you’ve even stored any value in it. How does that make sense?


Aside, you can only really assign/change variables on the right hand side of the = sign.

I can see where you have gone wrong, try this:

            Console.Write("YES or NO: ");
            string noiseChoice = Console.ReadLine();
            noiseChoice = noiseChoice.ToUpper();

When ever you use noiseChoice after that it will be in captials.
so you could print it to the console like so

            Console.Write("YES or NO: ");
            string noiseChoice = Console.ReadLine();
            noiseChoice= noiseChoice.ToUpper();
            Console.WriteLine(noiseChoice);