一看就明白了:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
private void MyFun()
{
throw new System.ArgumentException("数据库文件错误");
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MyFun();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
C#抛出异常与获取异常
最新推荐文章于 2024-08-15 18:51:17 发布