You have several issues here:
First of all, your string cu
is declared inside the if
scope. It will not exist outside that scope. If you need to use it outside the scope of the if
, declare it outside.
Second, math operations cannot be applied to string
s. Why are you casting your numeric values to string? Your code should be:
decimal totalamtforcushion = 0m;
if (cushioncheckBox.Checked)
{
totalamtforcushion = 63m * cushionupDown.Value;
//string cu = totalamtforcushion.ToString("C"); You don't need this
cushioncheckBox.Checked = false;
cushionupDown.Value = 0;
}
decimal totalamtforcesarbeef = 0m;
if (cesarbeefcheckBox.Checked)
{
totalamtforcesarbeef = 1.9m * cesarbeefupDown.Value;
//string cb = totalamtforcesarbeef.ToString("C"); you don't need this either
cesarbeefcheckBox.Checked = false;
cesarbeefupDown.Value = 0;
}
var totalprice = totalamtforcushion + totalamtforcesarbeef;
5
solved how to add strings together?