Re: Optimal use of foreach
Shawn Wildermuth <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <[email protected]> |
Only once... Thanks, Shawn Wildermuth http://wildermuth.com https://AgiliTrain.com http://silverlight-tour.com Microsoft MVP (C#), MCSD.NET, Author and Speaker The Silverlight Tour is coming to a city near you! -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of Mont Rothstein Sent: Tuesday, January 27, 2009 8:43 PM To: [email protected] Subject: [ADVANCED-DOTNET] Optimal use of foreach When using foreach if the collection is a property will it be called on each pass or only once? Can I do: foreach (string key in myDictionary.Keys) { } or will that call Keys each time, therefore requiring that I do: Dictionary<string, string>.KeysCollections keys; keys = myDictionary.Keys; foreach (string key in keys) { } Thanks, -Mont =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives