Moving the cursor over the method shows which exceptions can be thrown:


Screenshot of the help text

Screenshot of the help text


  1. using System;
  2.  
  3. namespace ExceptionCatch
  4. {
  5.     class Program
  6.     {
  7.         static void exceptionHandling()
  8.         {
  9.             String str =  "...";
  10.             int number = Int32.Parse(str);
  11.         }
  12.         static void Main(string[] args)
  13.         {
  14.             try
  15.             {
  16.                 exceptionHandling();
  17.             }
  18.             catch (FormatException fe)  
  19.             {
  20.                 Console.Write("Conversion not possible. " + fe.Message);
  21.             }
  22.             catch (ArgumentNullException ane)
  23.             {
  24.                 Console.Write("Conversion not possible. " + ane.Message);
  25.             }
  26.             catch (OverflowException oe)
  27.             {
  28.                 Console.Write("Conversion not possible. " + oe.Message);
  29.             }
  30.             /*
  31.              * If detailed exception handling is not necessary,
  32.              * you can alternatively only handle the exception of the superclass type.
  33.              *
  34.             catch (Exception e)
  35.             {
  36.                 Console.Write("Conversion not possible. " + e.Message);
  37.             }
  38.             */
  39.             Console.ReadKey();
  40.         }
  41.     }
  42. }

Last modified: Sunday, 25 August 2019, 6:07 PM