KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In Visual Studio Re-Sharper keeps recommending I convert a for loop to a linq expression but what is the reason for this? Which is faster? Here are some example loops where resharper suggests a linq conversion: foreach (XmlNode legendEntryNode in _legendEntryNodes) { var xmlElement = legendEntryNode["FeatureType"]; if (xmlElement == null || !xmlElement.InnerText.Equals(featuretype)) continue; var xmlNodeList = legendEntryNode.SelectNodes("Themes/Theme"); if (xmlNodeList != null) foreach (XmlNode themeNode in xmlNodeList) { var element = themeNode["Value"]; if (element == null || !element.InnerText.Equals(v)) continue; var xmlElement1 = themeNode["Icon"]; if (xmlElement1 != null) { string iconname = "<ms:ICON>" + xmlElement1.InnerText + "</ms:ICON>"; var element1 = themeNode["Highlight"]; if (element1 != null) { string highlightname = "<ms:HIGHLIGHT>" + element1.InnerText + "</ms:HIGHLIGHT>"; gml = gml.Insert(c, iconname + highlightname); c += (iconname.Length + highlightname.Length); } } break; } } And this simpler example: for (int i = 0; i < getPointsRequest.Attribs.Length; i++) { string attribName = getPointsRequest.Attribs[i].AttributeName; if (!String.IsNullOrEmpty(attribName)) { sqlQuery += "<ms:" + attribName + ">||\"" + attribName + "\"||</ms:" + attribName + ">"; } }
Tags (comma-separated)
Save Edits
Cancel