Pages

Saturday 4 June 2011

Example on Switch Condition.

0 comments
 
Hi friends,in this post i would like to explain Example on Switch Condition in C#.Net.

* Open windows application.
* Place a TextBox & a Button on to the form.

* Code under button_Click event:


{
int j=int.Parse(textBox1.Text);
Switch(j)
{
Case 1 : this.BackColor=Color.Green;
              break;

Case 2 : ColorDialog clrd=new ColorDialog();
              clrd.ShowDialog();
              this.BackColor=cd.Color;
              break;

Case 3 : Application.Exit();
              break;

default : MessageBox.Show("Please enter 1,2 or 3");
             break;

}//End of switch.
}//End of button_Click event.



Thank You...
Shout it

Leave a Reply