Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# linq select from object list

// 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();
Comment

c# linq list select

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();
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to make a singleton in unity 
Csharp :: c# dictionary loop key value 
Csharp :: c# substring from end 
Csharp :: c# map 
Csharp :: c# listbox delete selected items 
Csharp :: movement unity 
Csharp :: reverse a string in c# 
Csharp :: cast int to enum type c# 
Csharp :: increase timeout in .net core web app 
Csharp :: git find commits by message 
Csharp :: how get query from url in laravel 
Csharp :: dota2 
Csharp :: = in c# 
Csharp :: how to make panel scrollable c# 
Csharp :: scaffold single table to model ef core 
Csharp :: linq query select top 1 c# 
Csharp :: c# print console 
Csharp :: system.io.directorynotfoundexception c# 
Csharp :: c# onmousedown. unity 
Csharp :: selection sort in c# 
Csharp :: mapping dictionary to object c# 
Csharp :: c# contains 
Csharp :: 2d rotation unity 
Csharp :: unity play sound effect 
Csharp :: remove adjacent duplicate characters 
Csharp :: convert string to number c# 
Csharp :: instantiate unity 2d in parent 
Csharp :: c# get application root path directory 
Csharp :: Squares of a Sorted Array 
Csharp :: single line and multiline comments in c 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =