using System;
class Program
{
static void Main()
{
string s = "c# programming";
object obj = s;
int i = 88;
try {
i = (int)obj; // try to cast string to int = Error
Console.WriteLine("try");
}
catch (Exception ex) {
Console.WriteLine("catch (Exception ex): {0}", ex.GetType());
}
finally {
Console.WriteLine("\nfinally");
Console.WriteLine("i = {0}", i);
}
}
}
/*
run:
catch (Exception ex): System.InvalidCastException
finally
i = 88
*/