Home   Cover Cover Cover Cover
 

Ausnahmen

A02.cs
using System;

class Test {
  
  public static void Main(string[] arg) {
    foreach (string s in arg) {
      try {
        int i = Convert.ToInt32(s);
        Console.WriteLine("i = " + i);
      } catch (FormatException) {
        Console.WriteLine("the string \"{0}\" cannot be converted to an int", s);
      } catch (OverflowException) {
        Console.WriteLine("the string \"{0}\" is too big or too small for an int", s);
      }
    }
  }
}