自定义异常

定义一个类的静态方法(在静态方法中可定义满足某种条件,throw new AException (message))

 

自定义异常

public class AException : ApplicationException

{

  public AException(string message):base(message){}

}

 

使用:

  try

  {

    静态方法

  }

  catch(AException e)

  {

    Console.WriteLine("异常原因:{0}",e.Message);

  }

  

posted @ 2020-05-09 20:54  流星曳尾  阅读(123)  评论(0编辑  收藏  举报