none
cs1513 error, how do i fix it? RRS feed

  • Question

  • Cosole.WriteLine(" pick a door 1,2 or 3");

    String userValue;

    userValue= Console.ReadLine();

    If (userValue=="1");

    {

    Console.WriteLine("you won a car");

    Console.ReadLine();

    }

    else if (userValue=="2")~~~the problem occurs as soon as I type in else if

    Wednesday, November 22, 2017 2:20 PM

All replies

  • There is no semi-colon between the conditional expression of the 'if' statement and the body after it:

    If (userValue=="1")  // << No semi-colon here
    {
    Console.WriteLine("you won a car");
    Console.ReadLine();
    }
    else if (userValue=="2")
    {
      // other stuff
    }

    Wednesday, November 22, 2017 4:24 PM
  • Hi PlaykidZERO,

    Thank you for posting here.

    Please try the code below.

      Console.WriteLine(" pick a door 1,2 or 3");
                String userValue;
                userValue = Console.ReadLine();
    
                if (userValue == "1")
                {
                    Console.WriteLine("you won a car");
                    Console.ReadLine();
                }
                else if (userValue == "2")
                {
    
                }

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 23, 2017 7:27 AM
    Moderator