Random rd = new Random();
int question;
question = rd.Next(1,2);
if(question ==1)
{
label1.Text = "What is your name?";
}
if(question ==2)
{
label1.Text = "How old are you?";
}
これを短縮する方法はありますか? 私はこのようにする必要がありますが、より短いオプションを見つけることができます。ifsのないランダムな値ですか?
条件演算子を使用するのに適しています。 http://csharpindepth.com/Articles/Chapter12/Random.aspx –
こちらをご覧ください:http://codereview.stackexchange.com/ –