Accepted answer

You can use something like this:

var afterTop = fullHierarchy.SkipWhile(x => !x.IsTop).Skip(1);

The SkipWhile skips all elements until the first item is found where IsTop == true, then the Skip skips that element, too. The result will be all items in fullHierarchy after the first one where IsTop == true.


Try this:

var result = fullHierarchy.SkipWhile(x=>!x.IsTop).Skip(1);


I think that SkipWhile is what you're looking for, e.g.

var myArray = new[]
    new { IsTop = false, S = 'a' },
    new { IsTop = true, S = 'b' },
    new { IsTop = false, S = 'c' },
myArray.SkipWhile(x => !x.IsTop); // contains the elements with 'b' and 'c'

// in your code, might be
foreach (var config in fullHierarchy.SkipWhile(x => !x.IsTop))

Related Articles