是一個對像,實例化Expection的對像就好似Expection e=new Expection();通過這個對像,你可以查看到發生異常的一些信息Expection是一個處理異常的類

解决方案 »

  1.   

    这个是异常处理时,捕获异常后的Exception 对象,通过e.Message  可以获取异常信息
      

  2.   

    e代表一个Exception对象
    此对象通过try..catch扑获
    楼主可以想象Exception e = new Exception();
      

  3.   

    e.toString()跟e.Message有什么区别
      

  4.   

    e  就是一个异常的对象int i=4;
    我来解释一下这个吧
    这个i就是所谓的变量   而变量是什么呢?
    首先啊  常量  就是 在程序中不可以被改变量    反思变量呢?
    在程序中可以被改变的量? 这个是错的!
    变量 其实是 内存地址的别名 
    至于 int i = 4;
    写这个语句的时候  计算机会先在内存上 画出一块区域  而这个区域上的值 是 4
    但是我们调用 4这个值的时候 用内存地址来调用  太烦琐了  
    所以 就可以通过i 来调用 也就是说 i就是一个 内存地址的别名
    而这个别名所代表的内存地址上存放的值就是 4我是小菜鸟!   说的不好清见谅,   希望能够帮到你!
      

  5.   

    e是一个变量。里面包含了你的异常内容。你也可以用catch(Expection A)
    解释完毕
      

  6.   

    e是Expection实例化的一个对象!
    你可以取任意的名字!
    不一定是e~
      

  7.   

    e是Expection实例化的一个对象! 
    可以换成其他的名字,如ex
      

  8.   

    Expection e
    中e是Expection的一个对象!包含此对象的一些内部变量与方法
      

  9.   

    看msdn:Excepton.Message http://msdn.microsoft.com/zh-cn/library/system.exception.message(VS.85).aspxException.Message 属性
    获取描述当前异常的消息。 
    命名空间: System
    程序集: mscorlib(在 mscorlib.dll 中)语法
    C#
    public virtual string Message { get; }属性值
    解释异常原因的错误消息或空字符串 ("")。 
     备注 
    Message 的文本应当完全描述错误,并且如果可能,应阐释如何纠正错误。Message 属性的值包含在 ToString 所返回的信息中。仅当创建 Exception 时才设置 Message 属性。如果对于当前实例没有向构造函数提供消息,则系统将提供使用当前系统区域性格式化的默认消息。给实现者的说明: 如果您从某个属性引发了异常,而且需要在 Message 文本中引用您所设置或获取的属性参数,请使用“value”作为属性参数的名称。 给继承者的说明: 在需要控制消息内容或格式的类中重写 Message 属性。应用程序代码在需要显示捕捉到的异常的信息时通常会访问此属性。 应本地化错误消息
    // Example for the Exception.HelpLink, Exception.Source,
    // Exception.StackTrace, and Exception.TargetSite properties.
    using System;namespace NDP_UE_CS
    {
        // Derive an exception; the constructor sets the HelpLink and 
        // Source properties.
        class LogTableOverflowException : Exception
        {
            const string overflowMessage = "The log table has overflowed.";        public LogTableOverflowException( 
                string auxMessage, Exception inner ) :
                    base( String.Format( "{0} - {1}", 
                        overflowMessage, auxMessage ), inner )
            {
                this.HelpLink = "http://msdn.microsoft.com";
                this.Source = "Exception_Class_Samples";
            }
        }    class LogTable
        {
            public LogTable( int numElements )
            {
                logArea = new string[ numElements ];
                elemInUse = 0;
            }        protected string[ ] logArea;
            protected int       elemInUse;        // The AddRecord method throws a derived exception if 
            // the array bounds exception is caught.
            public    int       AddRecord( string newRecord )
            {
                try
                {
                    logArea[ elemInUse ] = newRecord;
                    return elemInUse++;
                }
                catch( Exception e )
                {
                    throw new LogTableOverflowException( 
                        String.Format( "Record \"{0}\" was not logged.", 
                            newRecord ), e );
                }
            }
        }    class OverflowDemo 
        {
            // Create a log table and force an overflow.
            public static void Main() 
            {
                LogTable log = new LogTable( 4 );            Console.WriteLine( 
                    "This example of \n   Exception.Message, \n" +
                    "   Exception.HelpLink, \n   Exception.Source, \n" +
                    "   Exception.StackTrace, and \n   Exception." +
                    "TargetSite \ngenerates the following output." );            try
                {
                    for( int count = 1; ; count++ )
                    {
                        log.AddRecord( 
                            String.Format( 
                                "Log record number {0}", count ) );
                    }
                }
                catch( Exception ex )
                {
                    Console.WriteLine( "\nMessage ---\n{0}", ex.Message );
                    Console.WriteLine( 
                        "\nHelpLink ---\n{0}", ex.HelpLink );
                    Console.WriteLine( "\nSource ---\n{0}", ex.Source );
                    Console.WriteLine( 
                        "\nStackTrace ---\n{0}", ex.StackTrace );
                    Console.WriteLine( 
                        "\nTargetSite ---\n{0}", ex.TargetSite );
                }
            }
        }
    }/*
    This example of
       Exception.Message,
       Exception.HelpLink,
       Exception.Source,
       Exception.StackTrace, and
       Exception.TargetSite
    generates the following output.Message ---
    The log table has overflowed. - Record "Log record number 5" was not logged.HelpLink ---
    http://msdn.microsoft.comSource ---
    Exception_Class_SamplesStackTrace ---
       at NDP_UE_CS.LogTable.AddRecord(String newRecord)
       at NDP_UE_CS.OverflowDemo.Main()TargetSite ---
    Int32 AddRecord(System.String)
    */Exception.ToString 方法
    创建并返回当前异常的字符串表示形式。 
    命名空间: System
    程序集: mscorlib(在 mscorlib.dll 中) 语法 
    C#
    public override string ToString ()返回值
    当前异常的字符串表示形式。 
     备注 
    ToString 返回当前异常的可读表示形式。当该异常包含区分区域性的数据时,ToString 所返回的字符串表示形式需要考虑当前系统区域性。虽然对于所返回字符串的格式没有确切的要求,但应当努力从用户的角度反映对象的值。ToString 的默认实现获取引发当前异常的类名、消息、对内部异常调用 ToString 的结果和调用 Environment.StackTrace 的结果。如果这些成员中有任何为 空引用(在 Visual Basic 中为 Nothing),则它的值不包含在返回的字符串中。如果没有错误消息或者错误消息是空字符串 (""),则不返回错误消息。仅当内部异常的名称和堆栈跟踪不为 空引用(在 Visual Basic 中为 Nothing) 时,才返回它们。此方法重写 Object.ToString。 示例 
    下面的示例将导致异常并显示对该异常调用 ToString 的结果。
    using System;public class MyClass {}
    public class ArgExceptionExample 
       {
       public static void Main()
          {
          MyClass my = new MyClass();
          string s = "sometext";
          try 
             {
             int i = s.CompareTo(my);
             }
                catch (Exception e) 
                {
                Console.WriteLine("Error: {0}",e.ToString());
                }
          }
    }