Home  |  Delphi .net Home  |  System.Exception  |  ToString Method
  
ToString  
Method  
Converts the Exception message and other information into a string
Exception Class
System NameSpace
CF1.  Function ToString : string;
CF : Methods with this mark are Compact Framework Compatible
Description
Generates a string that cnotains the error message along with culture sensitive information about the exception.
Microsoft MSDN Links
System
System.Exception
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
Illustrating ToString and the Message property
program Project1;
{$APPTYPE CONSOLE}

var
  x    : Integer;
  zero : Integer;

begin
  zero := 0;

  try
    x := 1 DIV zero;
    Console.WriteLine('Division succeeded x = {0}', x.ToString);
  except
    on e : Exception do
    begin
      Console.WriteLine('Exception message : ' + e.Message);
      Console.WriteLine;
      Console.WriteLine('Exception string  : ' + e.ToString);
    end;
  end;

  Console.ReadLine;
end.
   Exception message : Arithmetic operation resulted in an overflow.
  
   Exception string  : System.OverflowException: Arithmetic operation resulted in an overflow.
   at Project1.Unit.Project1() in C:\Documents and Settings\Neil\My Documents\Borland Studio Projects\Project1.dpr:line 12
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author