I am learning how to program so please be nice. :)
I have this error running the code:
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: Input string was not in a correct format.
When I type "screw you, don't tell me what to do!". When I delete the whole insult part of the code, it's working flawlessly. What am I doing wrong?
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
int numero1 = 5; //Declaring first variable
int numero2 = 5; //Declaring second variable
Console.WriteLine ("What is the answer of " + numero1 + " x " + numero2); //Asking question to the user
int answer = Convert.ToInt32(Console.ReadLine()); //Converting the "answer" to integral variable
string insult = Console.ReadLine(); //The user enter his insult
if (answer == 25) //If the answer is 25
{
Console.WriteLine("Good answer!"); //This message appears
}
else if (insult == "screw you, don't tell me what to do!") //If the user insult me
{
Console.WriteLine("Wow buddy, gotta check that language!"); //The user receives this message
}
else
{
Console.WriteLine("Dude...what?"); //If the user write anything else, he gets this message
}
Console.ReadKey();
}
}
}