Quiz #3

8

Posted on : 27-02-2008 | By : matteosp | In : C#, Quiz

Take the following snippet:

public class Foo
{
  // add code
  public static int MethodOne() { return 0; }
  public static string MethodTwo() { return string.Empty; }
}

public class Program
{
  public static void Main()
  {
    try { Foo.MethodOne(); }
    catch (Exception ex) { Console.WriteLine(ex.Message); }

    try { Foo.MethodTwo(); }
    catch (Exception ex) { Console.WriteLine(ex.Message); }
  }
}

and add the code necessary (you cannot modify in any way MethodOne and MethodTwo) to make both method invocation throw an exception.