Re: foreach vs. for
From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 03/28/04
- Next message: Bill McCarthy: "Re: foreach vs. for"
- Previous message: Alvin Bruney [MVP]: "Re: prejit or jitman"
- In reply to: cody: "Re: foreach vs. for"
- Next in thread: Bill McCarthy: "Re: foreach vs. for"
- Reply: Bill McCarthy: "Re: foreach vs. for"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 27 Mar 2004 23:30:08 -0800
You can read my full examination of these methods on my blog. for and
foreach under most circumstances have the same performance results, even
though they have different code. The semantics of foreach (storing a local
version of the array and a local copy of the array element) are required,
while you are allowed to manage these options yourself when using a for
loop.
http://weblogs.asp.net/justin_rogers/archive/2004/03/26/97230.aspx
-- Justin Rogers DigiTec Web Consultants, LLC. Blog: http://weblogs.asp.net/justin_rogers "cody" <please_dont.spam.deutronium@gmx.de> wrote in message news:edP$bXAFEHA.3344@tk2msftngp13.phx.gbl... > Also I wonder what the conv.i4 instruction is needed for. the lenght > property of array already returns an int so there is no need to convert > someting. I also noted that the conv instruction was apparent in the for() > version also. > > decompilation of the loop returned following code: > > for (int k5 = 0; k5 < (int)nums2.Length; k5++) > { > int k1 = nums2[k5]; > WriteLine("test"); > } > > note the cast of the length property. also there is an unnessacary > assignment of k1. > > -- > cody > > [Freeware, Games and Humor] > www.deutronium.de.vu || www.deutronium.tk > >
- Next message: Bill McCarthy: "Re: foreach vs. for"
- Previous message: Alvin Bruney [MVP]: "Re: prejit or jitman"
- In reply to: cody: "Re: foreach vs. for"
- Next in thread: Bill McCarthy: "Re: foreach vs. for"
- Reply: Bill McCarthy: "Re: foreach vs. for"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|