Curwen Arthurs

Curwen Arthurs

  • NA
  • 2
  • 1.4k

Convert Class Error

Jul 15 2022 3:56 PM

Hi. I am trying to convert a user input string to an int but getting this error.

Unhandled exception. System.FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.Convert.ToInt32(String value)
   at csharpfundamentals.Practice.Main(String[] args)

 

// Code snippet

Console.WriteLine("Enter a number: ");

string user_input = Console.ReadLine();

int number = Convert.ToInt32(user_input);

 

               


Answers (5)