Exception throw and catch 2
/*
Learning C#
by Jesse Liberty
Publisher: O'Reilly
ISBN: 0596003765
*/
using System;
namespace ExceptionHandling
{
public class TesterExceptionHandling3
{
static void Main()
{
Console.WriteLine("Enter Main...");
TesterExceptionHandling3 t = new TesterExceptionHandling3();
t.Run();
Console.WriteLine("Exit Main...");
}
public void Run()
{
Console.WriteLine("Enter Run...");
Func1();
Console.WriteLine("Exit Run...");
}
public void Func1()
{
Console.WriteLine("Enter Func1...");
try
{
Console.WriteLine("Entering try block...");
Func2();
Console.WriteLine("Exiting try block...");
}
catch
{
Console.WriteLine("Exception caught and handled!");
}
Console.WriteLine("Exit Func1...");
}
public void Func2()
{
Console.WriteLine("Enter Func2...");
throw new System.Exception();
Console.WriteLine("Exit Func2...");
}
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
|