Exception Handling:Trying and Catching : Exception Try Catch « Language Basics « C# / C Sharp
- C# / C Sharp
- Language Basics
- Exception Try Catch
Exception Handling:Trying and Catching

using System;
public class TryingCatching
{
static int Zero = 0;
public static void Main()
{
// watch for exceptions here
try
{
int j = 22 / Zero;
}
// exceptions that occur in try are transferred here
catch (Exception e)
{
Console.WriteLine("Exception " + e.Message);
}
Console.WriteLine("After catch");
}
}
Related examples in the same category