C# Exception ToString

Description

Exception ToString creates and returns a string representation of the current exception.

Syntax

Exception.ToString has the following syntax.


public override string ToString()

Returns

Exception.ToString method returns A string representation of the current exception.

Example


using System;/*from www.  j a va2  s.c o  m*/
public class MainClass{
  public static void Main(String[] argv){  
    Exception e = new Exception("asdf");
    
    System.Console.WriteLine(e.ToString());
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version