Define it outside the if statement.
double insuranceCost;
if (this.comboBox5.Text == "Third Party Fire and Theft")
{
insuranceCost = 1;
}
If you return it from a method, you can set it to the default value or 0, otherwise you may receive the error message "Using an unassigned variable";
double insuranceCost = 0;
or
double insuranceCost = default(double);
source
share