If Else Trouble

Chase Williams 1 Reputation point
2020-05-28T18:48:22.547+00:00

I'm just starting to learn learn C# and have started learning If Else statements. I could have sworn this programming worked but then after an update (I may be blaming something here that has nothing to do with it) to Visual Studio the if's and else's turned pink, they no longer worked, and it told me the "int numTemp = int.Parse(temperature);" line wasn't the correct format.

Hopefully someone can help me figure out what went wrong. There are no else's because I went back to the beginning of the lesson to start over and try to figure it out, but to no prevail.

using System;

namespace Retry
{
class MainClass
{
public static void Main(string[] args)
{
Console.WriteLine("What's the tempurature like?");
string temperature = Console.ReadLine();

        int numTemp = int.Parse(temperature);



        if (numTemp < 20)
        {
            Console.WriteLine("Argh!");
        }
        if (numTemp == 20)
        {
            Console.WriteLine("Ugh");
        }
        if (numTemp > 20)
        {
            Console.WriteLine("AAAHHH!!!");
        }

        Console.Read();

    }
}

}

Thank you in advance

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,551 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2020-05-29T11:37:48.723+00:00

    C# is not supported here on QnA. I'd try asking for help in dedicated forums here.

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=csharpgeneral

    --please don't forget to Accept as answer if the reply is helpful--


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.