none
Need help with Error 1513 RRS feed

  • Question

  • this is just a stupid personal project so dont pay any mind to stupid things please

    Edit: The problem has been resolved! Thanks very much to the person who help me.

    using System;

    namespace Meem_machine
    {
        class Program
        {
            static void Main(string[] args)
            {

                Console.Write("What is your name? ");
                string name =  Console.ReadLine();
                
                Console.WriteLine("Hello " + name);

                Console.Write("How old are you? ");
                string age = Console.ReadLine();

                Console.Write("What is the date today? ");
                string date = Console.ReadLine();

                Console.WriteLine("Your name is " + name + " and you are " + age + " and the date today is " + date);

                Console.Write("Is this info correct? Enter yes if correct, restart program if not.                                                     ");


                if (Console.ReadLine() == "Yes") ;

                {
                    Console.WriteLine("Welcome " + name);

                    else if (Console.ReadLine() == "No"); [!!this is where the error is!!] 
                    {
                        Console.WriteLine("Sorry please try again" + name);
                    }

                }
                } 
                
            }
        }



    • Edited by WaltJD Thursday, April 12, 2018 6:59 PM
    Thursday, April 12, 2018 5:02 PM

All replies

  • Hi,

    you are reading the console output multiple times:

    if (Console.ReadLine() == "Yes") ; reads once

    ...

    else if (Console.ReadLine() == "No"); [!!this is where the error is!!]  reads second time and so it tries to read the next line which probably doesnt exist.

    do something like

    string s = Console.ReadLine();
    
    if(s == "Yes")
     //[...]
    else if (s == "No")
     //[...] 

    Regards,

      Thorsten

    Thursday, April 12, 2018 5:13 PM
  • Thank you very much! This was helped with the problem.
    Thursday, April 12, 2018 6:58 PM
  • Hello WaltJD,

    Is there any update or any other assistance I could provide? You could mark the helpful reply as answer if the issue has been solved. And if you have any concerns, please do not hesitate to let us know.

    Best regards,

    Neil Hu


    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.

    Friday, April 13, 2018 4:51 AM
    Moderator