question

ChaseWilliams-9913 avatar image
ChaseWilliams-9913 asked ·

If Else Trouble

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-supported
2 comments
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I don't know what's happening with the post. those &# should be quotes or apostrophes thats not the problem

0 Votes 0 · ·

(num &lt 20) should have a < not &lt

&gt should be a >

0 Votes 0 · ·

1 Answer

DSPatrick avatar image
DSPatrick answered ·

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.




2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks, I just moved my question there.

0 Votes 0 · ·
DSPatrick avatar image DSPatrick ChaseWilliams-9913 ·

Sounds good, you're welcome.

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





0 Votes 0 · ·