Increase array value on every button click?

I am creating a calculator in C #. I'm not sure if the best way is to increase the number in the array every time the button is pressed. Here is one of my current button event handler methods:

    //Assign button '2' to 2 with array address of 1
    private void num2_Click(object sender, EventArgs e)
    {
        numbers[1] = 2;
        lblUpdate(1);
    }

      

I'd like so much that every time this button is pressed, the numbers [1] are incremented by 2. Right now, it just sets to 2 no matter how many times the button is pressed.

Many thanks!

0


source to share


3 answers


numbers[1] += 2;

      



+3


source


numbers [1] + = 2;



This should do the trick.

+3


source


numbers [1] + = 2;

+3


source







All Articles