expression must have bool type (or be convertible to bool)

I have been thru the other forums on this issue, but cannot find a solution to this issue. If anyone can provide some assistance, I would appreciate it. This error is showing for the "stateCode" int the "if" statement. See the following:

double salesTaxCalc(double totalSalesAmt, string stateCode)
{
double salesTaxAmt;
double totalSalesAmt;
string stateCode;
char KS;

if (stateCode = KS)
salesTaxAmt = totalSalesAmt * KS_SALES_TAX_RATE;
else
salesTaxAmt = totalSalesAmt * MO_SALES_TAX_RATE;

return salesTaxAmt;
}
You've put a single equals sign instead of double equals.
You've put a single equals sign instead of double equals.

Although equality wouldn't make sense either, since KS is an uninitialized char variable.

Perhaps you meant:

if (stateCode == "KS") ...
Last edited on
Thanks!!
Topic archived. No new replies allowed.