System.Reflection.MethodInfo mInfo = typeof(TypeParse).GetMethod("Add", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
[Serializable] void Main() { var addMethod = typeof(MyMath).GetMethod("Add"); var dynamicMethod = new DynamicMethod("", typeof(int), new[] { typeof(MyMath), typeof(int), typeof(int) }); // var il = dynamicMethod.GetILGenerator(); il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_1); il.Emit(OpCodes.Ldarg_2); il.Emit(OpCodes.Callvirt, addMethod); il.Emit(OpCodes.Ret); // var add = (Func<MyMath, int, int, int>)dynamicMethod.CreateDelegate(typeof(Func<MyMath, int, int, int>)); // var math = new MyMath(); var result = add(math, 1, 2); var method=MethodBase.GetCurrentMethod(); Console.WriteLine (method.Name); var body=method.GetMethodBody(); var attrs=method.CustomAttributes; foreach (var attr in attrs) { Console.WriteLine (attr.AttributeType); } Console.WriteLine (body.GetILAsByteArray()); var pars=method.GetParameters(); foreach (var param in pars) { Console.WriteLine (param.Name); } } // Define other methods and classes here string Get(){ return "dd";} public class MyMath { public int Add(int a, int b) { return a + b; } } } class SerializableAttribute :System.Attribute{ public SerializableAttribute() { }