In this examples teach you how we identifying the number is Even or Odd.
Check if theNumber is Even or Odd using if else Statement in C# Windows Form Application.
Form Design:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | private void button1_Click(object sender, EventArgs e) { int n = Convert.ToInt32(textBox1.Text); if(n%2==0) { label2.Text = "This number is even"; } else { label2.Text = "This number is odd"; } } |
Output: