定义一个类的静态方法(在静态方法中可定义满足某种条件,throw new AException (message))
自定义异常
public class AException : ApplicationException
{
public AException(string message):base(message){}
}
使用:
try
{
静态方法
}
catch(AException e)
{
Console.WriteLine("异常原因:{0}",e.Message);
}
原文:https://www.cnblogs.com/guomengkai/p/12860062.html