我做了一个简单的数字生成器,我有一个问题:生成器是否可以弹出“红色”、“蓝色”、“绿色”、“黄色”和“白色”而不是数字 1-5?
namespace zufallsgenerator
{
public partial class Form1 : Form
{
Random r = new Random();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnWhlie_Click(object sender, EventArgs e)
{
int summe = 0, z;
lblAnzeige.Text = " ";
while (summe <= 0)
{
z = r.Next(1, 6);
summe = summe + z;
}
lblAnzeige.Text += summe + "\n";
}
}
}