Resolved Error in if command

nikeedev

Member
Joined
Aug 2, 2021
Messages
11
Programming Experience
1-3
Hello, currently I don’t have the code to that program but my problem is that I have two variables(call both whatever you want), if I use if command on them to see if first variable is same as the other one, but I can’t as it stays as and error. I can make a small code snippet(it uses normal/regular “using system” library:
C#:
string Input = Console.ReadLine();
string repeatInput = Console.ReadLine();

if (Input == repeatInput)  {
     Console.WriteLine(“True”);
} else {
     Console.WriteLine(“False”);
}
 
Last edited by a moderator:
What error are you getting?
 
What error are you getting?
I used right now a online compiler, and it worked there but on my pc, it said that if commands can’t find true between two variables, which is quite weird, as I didn’t get that error in online compiler. Right now I don’t have time to reply or code this so I reply with an answer what it looks like on my pc
 
If I had to guess, on your PC, you were using the = operator, while on the online compiler you were correctly using the == operator. The former will return the same type as the destination of the assignment. The latter will return a Boolean. The if statement expects to find a Boolean.
 
If I had to guess, on your PC, you were using the = operator, while on the online compiler you were correctly using the == operator. The former will return the same type as the destination of the assignment. The latter will return a Boolean. The if statement expects to find a Boolean.
Maybe, maybe not. I will check with my code, else thanks for now!
 
If I had to guess, on your PC, you were using the = operator, while on the online compiler you were correctly using the == operator. The former will return the same type as the destination of the assignment. The latter will return a Boolean. The if statement expects to find a Boolean.
Hi, i'm back on my pc, and i checked code out, and you were right! Thank you so much ;))))), I'm so excited to begin coding!!!
 
Back
Top Bottom