samedi 31 octobre 2015

The name 'c' doesn't exist in current context [duplicate]

This question already has an answer here:

I've been writing this code to do the quadratic formula for me, but there's a problem found a problem right here:

        if (textBox2.Text != "")
        {
        string h = textBox2.Text;
        double c = double.Parse(h);
        }
        else if (textBox2.Text == "")
        {
        double c = 0;
        }
        // else error message

        //Delta
        double delta = (Math.Pow(b, 2)) - (4 * a * c);
        string dtxt = Convert.ToString(delta);

        label5.Text = dtxt;

The problem is, "The name 'c' doesn't exist in current context". That also happens with the values b, and a, which have the same conditions as c.

Aucun commentaire:

Enregistrer un commentaire