且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

按下按钮时输入新文字

更新时间:2023-12-03 20:18:04

String[] text = { "hello", "elephant", "pig", "dog" };

int count=0;
private void Button1_Click(object sender, EventArgs e)
{
    Label1.Text=text[(count%text.Length)];
    count++;
}


尝试类似的方法-

Try something like -

int count=0;
private void Button1_Click(object sender, EventArgs e)
{
    if (count > text.Length)
    {
           count = 0;
    }
    Label1.Text = text[count++];
}