Why my "if... else" condition does not run please?

Hello everyone I am really beginner and I am blocking on the last block of this code … I do not understand why if I return a word other than “NOTHING”, it is always the Console.WriteLine of the if which runs in any case!

Anyone would know why please?

Here my code

Thanks !

Hello @mehdibobigny, welcome to the forums! Notice what riddleAnswer is set to:

string riddleAnswer = "NOTHING";

So, in the comparison

if (riddleAnswer == "NOTHING")

Won’t riddleAnswer always equal "NOTHING"?

Thank you for your welcome and your answer codeneutrino !
But I confess to you that I do not understand.
I have well defined my variable string whose value is “NOTHING” and then I ask “if” riddleAnswer is equal to “NOTHING” print my Console.WriteLine else print the other …? I don’t see … I try passing to “if”! = “NOTHING” but it doesn’t change anything …I understand that the answer is always equal to “NOTHING” but I do not see …

If the riddleAnswer is always equal to nothing, then it doesn’t matter what input you give through the terminal/console, the if(riddleAnswer == "NOTHING") will always be true, which means the else will never run.

Ok yes I see, a great beginner’s mistake !! thank you very much for your help codeneutrino !

1 Like

Written like this everything is fine thank you again !!

1 Like