Throw Exception in finally statement
using System;
using System.Collections;
public class MainClass
{
static void Main() {
try {
try {
ArrayList list = new ArrayList();
list.Add( 1 );
Console.WriteLine( "Item 10 = {0}", list[10] );
}
finally {
Console.WriteLine( "Cleaning up..." );
throw new Exception( "I like to throw" );
}
}
catch( ArgumentOutOfRangeException ) {
Console.WriteLine( "Oops! Argument out of range!" );
}
catch {
Console.WriteLine( "Done" );
}
}
}
Output Cleaning up...
Done
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
|