LINQ, принимает сумму в пакете [закрыто]C#

Место общения программистов C#
Гость
LINQ, принимает сумму в пакете [закрыто]

Сообщение Гость »


Given a list of books like this:

class BookShelf { int Cost { get; set; } string Title { get; set; } = string.Empty; string[] listID { get; set; } = new string[0]; } string[] exampleIDs = { "book1", "book2", "book3" }; // IDs will vary, this is for illustration purposes only string[] exampleIDs2 = { "book4", "book5" }; // IDs will vary, this is for illustration purposes only var Books = new List { new BookShelf { Cost = 5, Title = "Title1", listID = exampleIDs }, new BookShelf { Cost = 5, Title = "Title2", listID = exampleIDs2 }, new BookShelf { Cost = 5, Title = "Title3", listID = exampleIDs }, new BookShelf { Cost = 5, Title= "Title4", listID = exampleIDs2 } }; I noticed that I could technically use something like this to get a subset list:

int current = 0; var result = Books.TakeWhile((value, index) => (current = current + value.listID.Count())

Источник: https://stackoverflow.com/questions/780 ... in-a-batch

Вернуться в «C#»