Exception Translation : throw : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » throw »

 

Exception Translation








    
 

using System;
using System.Reflection;


public class MyClass {
    public static void MethodA() {
        Console.WriteLine("MyClass.MethodA");
        throw new Exception("MethodA exception");
    }
}

public class Starter {
    public static void Main() {
        try {
            Type zType = typeof(MyClass);
            MethodInfo method = zType.GetMethod("MethodA");
            method.Invoke(null, null);
        } catch (Exception except) {
            Console.WriteLine(except.Message);
            Console.WriteLine("original: " + except.InnerException.Message);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» throw