C Linq Select From Object List

[Solved] C Linq Select From Object List | Scala - Code Explorer | yomemimo.com
Question : c# linq select from object list

Answered by : mingles444

// this will return the first correct answer,
// or throw an exception if there are no correct answers
var correct = answers.First(a => a.Correct);
// this will return the first correct answer,
// or null if there are no correct answers
var correct = answers.FirstOrDefault(a => a.Correct);
// this will return a list containing all answers which are correct,
// or an empty list if there are no correct answers
var allCorrect = answers.Where(a => a.Correct).ToList();

Source : https://stackoverflow.com/questions/13230468/linq-select-object-from-list-depending-on-objects-attribute/13230501 | Last Update : Wed, 25 Mar 20

Question : c# linq list select

Answered by : antti-veikkolainen

List<Model> newList = list.Where(m => m.application == "applicationname") .Select(m => new Model { application = m.application, users = m.users.Where(u => u.surname == "surname").ToList() }).ToList();

Source : | Last Update : Mon, 08 Feb 21

Answers related to c linq select from object list

Code Explorer Popular Question For Scala