Nor
CS0120 - Object refrence required for the non static field, method, or property "object.Equals(obj)"
// START HERE
Console.WriteLine("Welcome to this Math Quiz!");
Console.WriteLine("This is your first question");
// RNG
Random rnd = new Random();
int random1 = rnd.Next(-100, 100);
int random2 = rnd.Next(-100, 100);
Console.WriteLine("{0} - {1}?", random1, random2);
// Checks if answer is correct
float answer = random1 - random2;
string answeruser = Console.ReadLine();
Convert.ToInt32(answeruser);
if (answeruser.Equals(answer))
{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("False!");
}
39 replies
CS0120 - Object refrence required for the non static field, method, or property "object.Equals(obj)"
// Checks if answer is correct
int answer = random1 + random2;
Convert.ToBoolean(answer);
int answeruser = Console.ReadLine();
if (answeruser.Equals(answer))
{
Console.WriteLine("Correct!");
}
else
{
Console.WriteLine("False!");
}
so this is the improved code, the issue now is that it cant convert "string" to "int", how do i fix this?39 replies