mardi 29 septembre 2020

How do I add up all the numbers in the list box?

I want to add up all the numbers in the list box(while still keeping the numbers in it) after the while loop is completed.

    void Task3()
    {
        limit = Convert.ToInt32(tBNumber.Text);
        int finalN = limit + 100;
        int n = limit;
        int sum = 0;
        while (n < finalN )
        {
            if (n % 9 == 0)
            {
                lbAnswer.Items.Add(n);
                n++;
            }
            else
            {
                n++;
            }
        }
    }

Aucun commentaire:

Enregistrer un commentaire