score:12
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
.
score:5
Try this:
var result = fullHierarchy.SkipWhile(x=>!x.IsTop).Skip(1);
score:4
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))
{
configurationHierarchy.Add(config);
}
Source: stackoverflow.com
Related Articles
- How do I select everything in a list after the first occurence of?
- Select items from a list after the first occurrence of a character
- How to remove first occurence of element in List C# with LINQ?
- How do I select everything after the last instance of?
- Dynamic Linq select first in groups after GroupBy
- Select first word of list of strings and concat last char of the rest of items on list in linq
- LINQ select from first list
- Code First EF: While searching database table is it possible to retrieve list of items it has in DataModel?
- select from list which has same code
- How to loop through a child list of objects in Entity Framework 4.1 code first
- Linq - Retrieve first list after SelectMany
- Code First Entity Framework, select ViewModel - constructor with parameter
- how to select data by linq in many-to-many relationship in First code Entity framework 5
- Linq Select items where they are before a certain date or the first after
- How to Select new model list after GroupBy mothod in Linq?
- LINQ: how to zip 2 lists and select elements where first list is distinct?
- List or Array of String Contain specific word in Html Source Code
- Code first one to one select query
- Linq, select a list of the first expired record grouped by container
- Entity Framework Code First Select Item Based on Relationship
- c# Linq or code to extract groups from a single list of source data
- how do I select first ischecked property of list to true and rest false
- Linq query, select everything from one lists property that starts with a string in another list
- How to select entire row by distinct column MVC code first
- How to select first list item to null using Linq
- General method to select first row from every group in DataTable, give a List of grouping column
- Linq select objects in list where exists IN (A,B,C)
- Select multiple records based on list of Id's with linq
- Select Multiple Fields from List in Linq
- Linq code to select one item
- LINQ, Lambda Expression Skip n records, while averaging the skipped records
- Need a linq query where inclusion indicates property matches all values in secondary list
- json Cannot access child value on Newtonsoft.Json.Linq.JValue
- MongoDB linq C# select document where array of subdocumnets contain all values from string array
- VB.NET Group by two columns and write results to an array
- Assign anonymous in IF-ELSE statements
- Linq method to return a random set of records
- Linq Query - Find two most recent TimeStamps for each distinct Column A
- Caching LINQ expressions by equality
- Using LINQ to select the smallest, most common number in an array
- Removing and adding search filters with Linq
- ComboBox DataBinding DisplayMember and LINQ queries
- Add Try-Catch Block to XAML Code
- system.collections.generic.list to system.collections.generic.ienumerable
- Filter two lists on one property c# using linq
- Edit Row in LINQ
- Sort by Count Occurrences of a Word in list rows linq
- How do write LINQ query to do recursion?
- Simplify a method with LINQ to update a series of nested property values
- Cannot implicitly convert type 'object' to 'System.Collections.Generic.List<float>'