电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

关注性能:反射操作


发布日期:2022/3/12
 

测试代码

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

}

})

}

}

}

上一篇:表单提交中Get和Post方式的区别

下一篇:VB6实现MUI程序方法详解