#region how custom exception Console.WriteLine ( " Please enter the computer prices (an integer) -----> " ); the try { int inputPCNum = Convert.ToInt32 (Console.ReadLine ()); PcPrice P = new new PcPrice () ; P.SET (inputPCNum); Console.WriteLine ( " transaction, the customer is very satisfied with the price " ); } the catch (Exception EX) { // output abnormality information Console.WriteLine ( " ---------- ----- ---------------- processing anomaly " ); Console.WriteLine ( " exception information: {0} " , ex.Message); Console.WriteLine (ex.Data [ " Time " ]); Console.WriteLine ( " For more information Help exception: {0} " , EX .HelpLink); Console.WriteLine ( " --------------- abnormality in the end portion ----------------------- " ); } the finally { Console.WriteLine ( " up code is executed " ); } #endregion public class PcPrice { Internal voidSET ( int n-) { // check whether it is greater than 5000 IF (n-> 5000 ) { // create a custom object class exception e HiPriceException e = new new HiPriceException ( " Computer pricing than 5000, customer dissatisfaction adjust price " ) ; // add the current time to the target e Data property e.Data.Add ( " time " , String .Format ( " time of the exception: {0} " , the DateTime.Now)); // the help information e Url assigned to object attribute HelpLink e.HelpLink =" Www.baidu.com " ; the throw e; } // check whether it is greater than 3000 the else IF (n-< 3000 ) { // create a custom object class exception e HiPriceException e = new new HiPriceException ( " Computer pricing than 3000, the customer adjust satisfied price " ); // add the current time to the Data property e object e.Data.Add ( " time " , String .Format ( " time of the exception: {0} " , the DateTime.Now)) ; //HelpLink property Url help information assigned to the object e e.HelpLink = " www.baidu.com " ; the throw e; } Console.WriteLine ( " this computer pricing 0} { " , n-); } } // / <Summary> /// custom exception class HiPriceException, and inherits ApplicationException /// </ Summary> class HiPriceException: ApplicationException { // default constructor Internal HiPriceException () {} // overloaded constructor, inherits method Internal HiPriceException ( String m):base(m) { } }