C# Exercises

Home AgriMetSoft About Contact

While Loop in C#

	
public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
      int i = 0;
      string s = "";
      while (i <= 10)
      {
        s += (i + 1).ToString() + ", ";
        i++;
      }
      MessageBox.Show(s);
    }
    private void button2_Click(object sender, EventArgs e)
    {
      int i = 0;
      string s = "";
      while (true)
      {
        s += (i + 1).ToString() + ", ";
        if (i == 10)
        { break; }
        i++;
      }
      MessageBox.Show(s);
    }
  }
	


Download the project of Visual Studio 2013 in DropBox Download


C#.Net While Loop || Windows Forms Application|| Visual Studio 2013


List of Exercises