Let us assume the code I use to iterate through a node list
foreach(XmlNode nodeP in node.SelectNodes('Property')) { propsList.Add(nodeP.Attributes['name'].Value, true); }
in this case does the expression node.SelectNodes(‘Property’) , get evaluated during each iteration of for each or once?
Only once. The foreach statement is syntactic sugar for (in your case)…
So the actual call to
SelectNodes()only happens one time.