给个猜数的,,也是随机的!改下值就可了!
private void button1_Click(object sender, System.EventArgs e)
{
int userGuess=Int32.Parse (textBox1.Text );
Random rnd=new Random ();
double correctNumber=rnd.NextDouble ()*10;
correctNumber=Math.Round (correctNumber);
string str="正确的数字是"+correctNumber+","+"你猜的数字是"+userGuess+"\n";
if(userGuess==correctNumber)
MessageBox.Show (str,"祝贺你,猜中了");
else
MessageBox.Show (str,"欢迎你参加竞猜,下次再来");
}