int price;
if (listBox1.Text == "Regular McYum")
{
price = 70;
}
How come the 'price' variable is assigned but never used?
int price;
if (listBox1.Text == "Regular McYum")
{
price = 70;
}
How come the 'price' variable is assigned but never used?
The warning is just clear: assigning a variable and using it are different things. The first is you set a value to it, the second ones means you´re doing something with that value.
So in your case you should pass your variable to a method for example:
Console.WriteLine(price);
This should be a warning from your compiler, so you can - although you shouldn´t - ignore this.
If listBox1.Text
does not equal "Regular McYum", then price
will never get set. You need to ensure that price
will receive a value on all of the possible code paths.