我用的是C#写的程序,我在执行程序的时候,如果在中间某个环节出现了错误,就在此中止程序的运行.如何实现.
如下例子,我如果想在else之前中止程序的运行,应该怎么样来操作.
CourseID = Int32.Parse(this.DrownCourseList.SelectedValue);
string ResourceName = this.resourceName.Text.Trim();
DateTime dt = DateTime.Now;
if (this.DrDownResourceType.SelectedIndex == 0)
{
this.LbT.Visible = true;
this.LbT.Text = "请选择资源类别";
}
else
{
KindID = this.DrDownResourceType.SelectedIndex;
}
如下例子,我如果想在else之前中止程序的运行,应该怎么样来操作.
CourseID = Int32.Parse(this.DrownCourseList.SelectedValue);
string ResourceName = this.resourceName.Text.Trim();
DateTime dt = DateTime.Now;
if (this.DrDownResourceType.SelectedIndex == 0)
{
this.LbT.Visible = true;
this.LbT.Text = "请选择资源类别";
}
else
{
KindID = this.DrDownResourceType.SelectedIndex;
}
{
}
catch
{
application.exit();
}
不知道你是不是这个意思