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 :: c# export datatatble to excel 
Csharp :: ignore ssl c# 
Csharp :: c# bool to int 
Csharp :: listview imagelist c# 
Csharp :: slither io hack 
Csharp :: string c# 
Csharp :: get min date in list c# 
Csharp :: c# round to closest multiple 
Csharp :: c# async constructor 
Csharp :: fluent api 
Csharp :: how to use double in c# 
Csharp :: c# list remove by index 
Csharp :: c# tab select tab 
Csharp :: how to return a value in c# 
Csharp :: select distinct linq mvc 
Csharp :: c# access substring 
Csharp :: get index brushes properties c# 
Csharp :: asp net saber ip address of client machine IIS 
Csharp :: start a particle effect when a button is pushed 
Csharp :: monogame print 
Csharp :: C# scrape html document 
Csharp :: C# top down view player movement 
Csharp :: Comparing Arrays using LINQ in C# 
Csharp :: how to fill model enum with bradio button asp razor 
Csharp :: c# dictionary check if value exists 
Csharp :: wpf get name of clicked element 
Csharp :: length of list c# 
Csharp :: array in c# 
Csharp :: c# clear panel 
Csharp :: c# if break 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =