0

I run this program but it does not assign the value of or 3 to s, instead before running it gave the sintax error unassigned local variable 's'

        private void button1_Click(object sender, EventArgs e)
        {
            int i, y, s;
            i = 8;
            y = 6;
                if (i == 6)
                {
                    s = y;
                }
                else
                {
                   s = 3;
                }
                listBox1.Items.Add(s)
        }
2
Contributors
3
Replies
17
Views
3 Years
Discussion Span
Last Post by lostC#
0

i ve tested your code and it works, by the way put a semicolon after your last line of code altouhg i think that this is not the problem.

listBox1.Items.Add(s);
0

I put the semicolon forgot it when I pass to this site.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.