c# - Cannot implicitly convert type "int" into Bool -
this question has answer here:
int valueone, valuetwo, numchar, total; console.writeline("this program doing of 4 mathematical proccesses"); console.writeline("you can add , substract , divide , multiply"); console.writeline("when asked please type values or proccesses want."); console.writeline("please type first value"); valueone = convert.toint32((console.readline())); console.writeline("please type second value"); valuetwo = convert.toint32((console.readline())); console.writeline("please enter number of proccess/character want meaning (1 = +) , (2 = -) , (3 = *) , (4 = /)"); numchar = convert.toint32((console.readline())); if ((numchar) = 1) total = valueone + valuetwo; if ((numchar) = 2) total = valueone + valuetwo; if ((numchar) = 3 total = valueone * valuetwo; if ((numchar) = 4 total = valueone / valuetwo;
this console application using c# , gives me error : "if ((numchar) = (number)" i'm beginner in visual studio , started taking courses
if ((numchar) = 1)
should be
if (numchar == 1)
= assigning value
== comparing values
edit: , comments point out, missed closing parentheses in 3rd , 4th if statements
if ((numchar) = 3
should be
if (numchar = 3)
and drop parentheses around numchar, pointless
Comments
Post a Comment