Performance Comparison Between foreach and

Source: Internet
Author: User

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          // Jump below "1 byte full 1" 13 000000fa  call        65C86690          // The address is so large that it should be an external 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 + "" );
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.