What is the most efficient way to traverse a collection/IEnumeration in C#. I have a list which contains almost 1100 objects. almost 10 of those objects, inturn contain 1000 subobjects (of same type). Traversal to this list takes almost 5-6 seconds. Here is my code:
foreach (Parameter par in this.AllParameters) //this.AllParameters is Generic.List type
{
foreach (Parameter subPar in par.WrappedSubParameters)
{
subPar.IsSelected = false;
}
par.IsSelected = false;
}
Is there a way to optimize this code so that it is fast enough, not taking 5-6 seconds?