zoukankan      html  css  js  c++  java
  • Exception

     1 using System;
     2 
     3 public class DataHouse
     4 {
     5     public static void FindData( long ID) 
     6     {
     7         if( ID>0 && ID<1000)
     8             Console.WriteLine( ID );
     9         else
    10             throw new DataHouseException("已到文件尾");
    11     }
    12 }
    13 
    14 public class BankATM 
    15 {
    16     public static void GetBalanceInfo( long  ID) 
    17     {
    18         try 
    19         {
    20             DataHouse.FindData(ID);
    21         }
    22         catch (DataHouseException e) 
    23         {
    24             throw new MyAppException("账号不存在",e);
    25         }
    26     }
    27 }
    28 
    29 //DataHouseException
    30 public class DataHouseException:ApplicationException 
    31 {
    32     public DataHouseException( string message )
    33         :base(message)
    34     {}
    35 }
    36 
    37 public class MyAppException:ApplicationException 
    38 {
    39     public MyAppException (string message) 
    40         : base (message) 
    41     {}
    42 
    43     public MyAppException (string message, Exception inner)
    44         : base(message,inner)
    45     {}   
    46 }
    47 
    48 public class Test 
    49 {
    50     public static void Main() 
    51     {
    52         try 
    53         {
    54             BankATM.GetBalanceInfo( 12345L);
    55         }
    56         catch(Exception e) 
    57         {
    58             Console.WriteLine ("出现了异常: {0}", e.Message);
    59 
    60             Console.WriteLine ("内部原因: {0}",e.InnerException.Message);
    61         }
    62     }
    63 }
  • 相关阅读:
    新手建站必看
    88.com域名邮箱免费注册了
    屏蔽博客园的广告
    跳过烦人的hCaptcha验证
    pap.er 专为 Mac 设计的壁纸应用
    TrafficMonitor
    利用CloudFlare自动DDNS
    P.SDA1.DEV
    谷歌浏览器又隐藏的HTTPS和WWW前缀
    谷歌浏览器扩展 crx 下载
  • 原文地址:https://www.cnblogs.com/GoldenEllipsis/p/10545999.html
Copyright © 2011-2022 走看看