try
{
    int i = 0;
    int a = 10 / i;
}
catch (Exception ex)
{
    /**
     * 1.异常消息
     * 2.异常模块名称
     * 3.异常方法名称
     * 4.异常行号
     */
    String str = "";
    str += ex.Message + "\n";//异常消息
    str += ex.StackTrace + "\n";//提示出错位置,不会定位到方法内部去
    str += ex.ToString() + "\n";//将方法内部和外部所有出错的位置提示出来
    MessageBox.Show(str);
} 

记录下来主要是为了记录系统异常日志所使用

相关文章:

  • 2021-11-08
  • 2021-08-18
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2021-11-30
相关资源
相似解决方案