using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace xunhuantest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
MessageBox.Show("i当前为:"+ i.ToString());
}
MessageBox.Show("循环结束,再见");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
int[] ary =new int[]{2,3,5};
foreach (int a in ary)
{
MessageBox.Show(a.ToString());
}
MessageBox.Show("遍历结束");
}
private void button3_Click(object sender, EventArgs e)
{
int a = 1;
while (a < 6)
{
MessageBox.Show(a.ToString());
a=a+1;
}
MessageBox.Show("循环结束!");
}
private void button4_Click(object sender, EventArgs e)
{
int a = 1;
do
{
MessageBox.Show(a.ToString());
a++;
} while (a < 6);
MessageBox.Show("循环结束");
}
private void button5_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
MessageBox.Show(i.ToString());
if(i==3)
{
MessageBox.Show("恭喜,找到了3");
}
else if(i==5)
{
MessageBox.Show("恭喜,找到了5");
break;
}
}
}
}
}