帮忙给下面的代码写下注释 考试要背的
在form窗体中生成随机函数using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace suijihanshu
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int n =0;
private void button1_Click(object sender, EventArgs e)
{
int k = int.Parse(textBox1.Text);
if (n < 3)
{
if (k == i)
{
MessageBox.Show("恭喜你,猜中了!");
n = 0;
}
else
{
if (k > i)
{
MessageBox.Show("大了!剩余次数:"+(2-n).ToString());
}
if (k < i)
{
MessageBox.Show("小了! 剩余次数:"+(2-n).ToString());
}
n++;
}
}
else
{
MessageBox.Show("你啊是弱智啊!!!!数字是:"+i.ToString());
}
}
private void button2_Click(object sender, EventArgs e)
{
Create();
//MessageBox.Show(i.ToString());
n = 0;
textBox1.Text = "";
}
public int i;
public void Create()
{
Random rn = new Random();
i = rn.Next(0, 10);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
} --------------------编程问答--------------------
补充:.NET技术 , 非技术区