c# - if statement error: int conversion to boolean -


public static void main(string[] args) // method called "main". called when program starts. {      random numbergenerator = new random();      int userinput1;     int userinput2;     int finaluserinput;     int thecorrectanswer;      //generating random numbers. 1 10. 11 exclusive.     userinput1 = numbergenerator.next(1, 11);     userinput2 = numbergenerator.next(1, 11);      //asks user solve multiplication problem.     console.write("what " + userinput1 + " x " + userinput2 + " ?");         finaluserinput = convert.toint32(console.readline());         thecorrectanswer = userinput1 * userinput2;      if(finaluserinput = thecorrectanswer) 

hi. when try set if statement conditions, error message pops saying cannot implicitly convert int boolean. i'm not trying @ all. i'm quite lost. help!

you setting value of thecorrectanswer variable finaluserinput using single =. , statement returns value – integer one.

you need use == compare 2 values.

it's typo or syntax error.


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -