测试代码 View Code using System; using SystemCollectionsGeneric; using SystemLinq; using SystemText; using SystemReflection; namespace CSharpStudy { class Program { static void Main(string[] args) { { dynamic dynamicObject = new StringBuilder() HelperWatch(() => { for (var i = ; i < ; i++) { dynamicObjectAppend(hello) } }) } { var appendMethod = typeof(StringBuilder)GetMethod(Append new Type[] { typeof(string) }) var sb = new StringBuilder() HelperWatch(() => { for (var i = ; i < ; i++) { appendMethodInvoke(sb new object[] { hello }) } }) } { var appendMethod = typeof(StringBuilder)GetMethod(Append new Type[] { typeof(string) }) var sb = new StringBuilder() var appendAction = (Func<string StringBuilder>)DelegateCreateDelegate(typeof(Func<string StringBuilder>) sb appendMethod) HelperWatch(() => { for (var i = ; i < ; i++) { appendAction(hello) } }) } } } |