在我的工作中,我们有一些可以推销的产品。可以使用不同的音调。目前,我的程序只允许对每种产品进行一次推介。例如,假设产品是“Live Help”。如果您在我的程序中单击该产品按钮,它会将文本输出到标签框。我用
做了这个label2.Text="have you heard of our live help service blah blah blah"; label2.Refresh();
我需要做什么才能让每个按钮使用 2-3 个音高?我总共有 5 个按钮,大约 12 个音高。
假设使用 WinForms,这是一种简单的方法,可以在每次单击其中一个按钮时出现随机音调:
private Random rnd = new Random();
private void button1_Click(object sender, EventArgs e)
{
String[] pitches = {
"24/7 tech support at your fingertips",
"on-site technician within 24 hrs",
"phone services to meet all your needs",
"we install updates during your closed hours!",
"chocolate delivered whenever you need it",
"we'll heat up your frozen lunch for you!"
};
label1.Text = pitches[rnd.Next(pitches.Length)];
}
private void button2_Click(object sender, EventArgs e)
{
String[] pitches = {
"have you heard of our live help service blah blah blah",
"unicorns are real!",
"call now to extend your car's warranty",
"click here to learn more about our outstanding bridges!"
};
label2.Text = pitches[rnd.Next(pitches.Length)];
}