Tag Info

New answers tagged


While not very scientific or accurate, we resorted to stop watch timing of file "ready" between the cloud and local environments accessing the same set of files.


As long as you stick to the principle of storing the SPListItemCollection in a variable before looping through the items, the difference between using for instead of foreach is close to redundant. The foreach loop will be converted into a for loop under the hood. It's a 1, perhaps 2 sec, difference. So if you write: var listItems = ...


Generally speaking you will want to use SPQuery to only query items you're interested in. Unless you're doing SPList oList = web.GetList("XYZ"); for(int i=0; i < oList.Items.Count; i++) { string strLstItemName = oList.Items[i].Name; // << BAD, as you use Items here, so you fetch them from DB each loop } there shouldn't be any relevant ...


In the context of general c# comparistions between for and foreach - There is a pretty comphrensive discussion here for loops on List are a bit more than 2 times cheaper than foreach loops on List. Looping on array is around 2 times cheaper than looping on List. As a consequence, looping on array using for is 5 times cheaper than looping on List ...

Top 50 recent answers are included