Есть следующая программа.
using System;
namespace ConsoleApplication1
{
class GenericException : Exception
{
}
class ChildExceptionA : GenericException
{
}
class ChildExceptionB : GenericException
{
}
class Class1
{
[STAThread]
static void Main(string[] args)
{
try
{
try
{
Console.WriteLine("Before B thrown");
throw new ChildExceptionB();
}
catch(ChildExceptionB)
{
Console.WriteLine("Got B exception !");
Console.WriteLine("Catch block throws A!");
throw new ChildExceptionA();
}
finally
{
Console.WriteLine("Finally block throws B!");
throw new ChildExceptionB();
}
}
catch(GenericException gex)
{
Console.WriteLine("Caught " + gex.GetType().ToString());
Console.ReadLine();
}
}
}
}
Есть ее вывод :
Before B thrown
Got B exception !
Catch block throws A!
Finally block throws B!
Caught ConsoleApplication1.ChildExceptionB
Внимание вопрос! Куда делся ChildExceptionA ?
29.08.05 06:36: Перенесено из 'Философия программирования'