多按钮按下

-4 c# button

我有4个标签,可见性设置为false和一个按钮.每次我点击按钮,我都希望它显示一个不同的标签.有人可以告诉我这个代码吗?

Ser*_*rvy 6

A Queue是为此任务量身定制的.

private Queue<Label> queue = new Queue<Label>();
//add labels to queue in constructor

private void button1_Click(object sender, EventArgs e)
{
    queue.Peek().Visible = false; //hide label at the start of the queue
    queue.Enqueue(queue.Dequeue()); //move the first item to the end
    queue.Peek().Visible = true; //show the label at the start of the queue
}
Run Code Online (Sandbox Code Playgroud)