/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy
Publisher: Sybex;
ISBN: 0782129110
*/
/*
Example13_2.cs illustrates the use of a
System.Exception object
*/
using System;
public class Example13_2
{
public static void Main()
{
try
{
int zero = 0;
Console.WriteLine("In try block: attempting division by zero");
int myInt = 1 / zero; // throws the exception
}
catch (System.Exception myException)
{
// display the exception object's properties
Console.WriteLine("HelpLink = " + myException.HelpLink);
Console.WriteLine("Message = " + myException.Message);
Console.WriteLine("Source = " + myException.Source);
Console.WriteLine("StackTrace = " + myException.StackTrace);
Console.WriteLine("TargetSite = " + myException.TargetSite);
}
}
}
|