using System;
class Test
{
static void Main()
{
/*
try
{
int n=10;
int m=0;
float f=n/m;
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("finally");
}
Console.WriteLine("finally later");
//*/
/*
try
{
int n=10;
int m=0;
float f=n/m;
}
catch(Exception e)
{
Console.WriteLine("ERROR");
}
finally
{
Console.WriteLine("finally");
}
Console.WriteLine("finally later");
//*/
/*
try
{
int n=10;
int m=0;
float f=n/m;
}
//這里應該把庇配度高的異常放到前面,依次是庇配度越低的
//自然Exception也就放在最後面.
catch(DivideByZeroException e)
{
Console.WriteLine(e.Message);
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("finally");
}
Console.WriteLine("finally later");
//*/
/*
try
{
int n=10;
int m=0;
float f=n/m;
}
//此處catch後面沒有跟(Exception e)
//程序會認為是catch(Exception e)
catch
{
Console.WriteLine("ERROR");
}
finally
{
Console.WriteLine("finally");
}
Console.WriteLine("finally later");
//*/
/*
try
{
string s = null;
if(s==null)
{
throw new ArgumentNullException();
}
}
catch
{
//這里拋出一個異常
Console.WriteLine("接收到拋出的異常");
}
finally
{
Console.WriteLine("finally");
}
Console.WriteLine("finally later");
//*/
}
}