/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Manually throw an exception.
using System;
public class ThrowDemo {
public static void Main() {
try {
Console.WriteLine("Before throw.");
throw new DivideByZeroException();
}
catch (DivideByZeroException) {
// catch the exception
Console.WriteLine("Exception caught.");
}
Console.WriteLine("After try/catch block.");
}
}
|