Song Lee

Song Lee

  • NA
  • 47
  • 38.4k

Another do, if method that I'm trying out.

Oct 19 2014 8:03 PM
Hello, I am trying out different ways to receive int number from user. If the input is not an int number, it gives out an error message.
 But I seem to be getting error messages on the highlighted parts.
 
"Since ___________ Returns a void, a return keyword must not be followed by an object expression "
 
public static void FirstInput()
{
         do
       {
 
            fromF = 0;
            if (int.TryParse(Console.ReadLine(), out fromF))
            {
                      return fromF;
             }
              Console.WriteLine("Error");
            {
                      return FirstInput();
             }
        }
 
       
Thanks for the help! 

Answers (5)