So I am trying to create a program which is a hire program, I have stored 2 values as a double variable (the first one is set to the value £3.00 and the second one is set to £1.00 and I have a 2 text boxes:
- The first textbox is where the user will type how many hours they want.
- The second textbox will display the result of multiplying txtHours by costPerHour and adding £1.00 for insurance where required by the user.
The problem I am having is that it is giving the following error:
Error CS0019 Operator '*' cannot be applied to operands of type 'string' and 'double'
I have tried everything including the parse technique but it still won't work could someone please take a look at the code below and tell me where I have gone wrong?
private void button2_Click_1(object sender, EventArgs e)
{
double costPerHour = 3.00;
double costOfInsurance = 1.00;
if (chbInsurance.Checked == true)
txtCost.Text = txtHours.Text * costPerHour + costOfInsurance;
else
txtCost.Text = txtHours.Text * costPerHour;
}