关于try catch方法,我有一个非常简单的问题(我是c#visual studio的新手):
CREATE TABLE Student (
student_id varchar2(25),
student_name varchar2(25),
major varchar2(10),
gpa number(3,2),
PRIMARY KEY(student_id)
);
CREATE TABLE Class (
schedule_num varchar2(25),
semester varchar2(25),
course_name varchar2(25),
course_number varchar2(25),
credit varchar2(4),
department varchar2(25),
meeting_time varchar2(25),
meeting_place varchar2(25),
class_size_limit varchar2(25),
PRIMARY KEY(schedule_num, semester)
);
CREATE TABLE Enrolls (
semester varchar2(25),
grade varchar2(2),
student_id varchar2(25) REFERENCES Student(student_id),
schedule_num varchar2(25),
FOREIGN KEY (schedule_num, semester) REFERENCES Class(schedule_num, semester),
PRIMARY KEY(student_id ,schedule_num, semester)
);
我尝试将try
{
double seven = 7
MessageBox.Show("You Picked 7!");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
替换为MessageBox.Show(ex.Message);
但不起作用。
我该如何处理? (“请输入数字。”)下面有错误行。 提前谢谢!
答案 0 :(得分:-2)
在宣布七个'
之后你错过了分号以下示例适用于我。
try
{
double seven = 7;
MessageBox.Show("You Picked 7!");
}
catch(Exception ex)
{
MessageBox.Show("Please enter a number.");
}
如果您计划不使用例外,请提示您,但建议您不要将异常指定为要捕获的参数。见Using catch without arguments
try
{
double seven = 7;
MessageBox.Show("You Picked 7!");
}
catch
{
MessageBox.Show("Please enter a number.");
}