foreach与for的性能比较
1
string
[] strings =
new
string
[] {
"str1"
,
"str2"
,
"str3"
,
"str4"
,
"str5"
,
"str6"
};
2
foreach
(
string
s
in
strings)
3
{
4
textBox1.AppendText(s +
" "
);
5
}
IL:
01
foreach
(
string
s
in
strings)
02
000000e0 nop
03
000000e1 mov eax,dword ptr [ebp-44h]
04
000000e4 mov dword ptr [ebp-50h],eax
05
000000e7 xor edx,edx
06
000000e9 mov dword ptr [ebp-54h],edx
07
000000ec nop
08
000000ed jmp 00000136
//jmp to J1
09
000000ef mov eax,dword ptr [ebp-54h]
10
000000f2 mov edx,dword ptr [ebp-50h]
11
000000f5 cmp eax,dword ptr [edx+4]
12
000000f8 jb 000000FF
//低于"1个字节全是1"跳转
13
000000fa call 65C86690
//地址如此之大,应该是个外部call
14
000000ff mov eax,dword ptr [edx+eax*4+0Ch]
15
00000103 mov dword ptr [ebp-48h],eax
16
{
17
00000106 nop
18
textBox1.AppendText(s +
" "
);
补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,