visual c#.net编程提问

来源:百度知道 编辑:UC知道 时间:2024/05/18 01:42:43
为小学生设计测验程序,随机生成个位数加法题(如3+8=),让小学生输入一个答案,若答案正确则程序停止,若答案错误则要求继续输入正确答案。

谁能把代码告诉我呢???
谢谢了阿

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Random rdo = new Random();

Label1.Text = rdo.Next(0, 9).ToString();

Label2.Text = rdo.Next(0, 9).ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int Add = int.Parse(Label1.Text.ToString()) + int.Parse(Label2.Text.ToString());
if (this.TextBox1.Text != string.Empty)
{
try
{
int a = int.Parse(TextBox1.Text.Trim());

}
catch
{
Label3.Text = "格式不对";
return;
}
}
else
{
Label3.Text = "不能为空";
return;
}
if (int.Parse(this.TextBox