private static void _Method2(int a, int b) { var obj = new RefectionTestObject(); var add = obj.GetType().GetMethod("Add"); for (int i = 0; i < _TIMES; ++i) { add.Invoke(obj, new object[] { a, b }); } }
private static void _Method5(int a, int b) { var obj = new RefectionTestObject(); var add = obj.GetType().GetMethod("Add"); var d = (AddMethod)Delegate.CreateDelegate(typeof(AddMethod), obj, add); for (var i = 0; i < _TIMES; i++) d(a, b); }