Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# filter list

List<int> myList = GetListOfIntsFromSomewhere();

// This will filter out the list of ints that are > than 7, Where returns an
// IEnumerable<T> so a call to ToList is required to convert back to a List<T>.
List<int> filteredList = myList.Where( x => x > 7).ToList();
Comment

how to filter a list in c#

using System;
using System.Collections.Generic;

var vals = new List<int> {-1, -3, 0, 1, 3, 2, 9, -4};

List<int> filtered = vals.FindAll(e => e > 0);

Console.WriteLine(string.Join(',', filtered));
Comment

PREVIOUS NEXT
Code Example
Csharp :: action delegate c# 
Csharp :: list contains type c# 
Csharp :: unity read console log 
Csharp :: sqlite execute 
Csharp :: how to auto format c# code in visual studio 
Csharp :: unity trygetcomponent 
Csharp :: how to add object in dictionary in c# 
Csharp :: System.Collections.Generic.List`1[System.Int32] c# fix 
Csharp :: cloudmailin c# 
Csharp :: AuthenticationTicket authenticationProperties C# .net 
Csharp :: Unity Input Key Message 
Csharp :: dotnet core clickable row 
Csharp :: Count Rows of table using Linq 
Csharp :: convert string to float win forms 
Csharp :: Bedingungen in C# – if, else und else if 
Csharp :: blazor editform empty 
Csharp :: wpf mvvm crud example 
Csharp :: sdl quit event not working multiple windows 
Csharp :: photon 
Csharp :: psobject get service name 
Csharp :: mvc dotnet core how does the view pass parameters to controler 
Csharp :: whining 
Csharp :: add auto mapper in startup 
Csharp :: linqkit predicatebuilder or and nested combined predicates 
Csharp :: c# if combobox selected index 
Csharp :: Filter list contents with predicate (anonymous method) 
Csharp :: c# statements 
Csharp :: c# class where T : enum 
Csharp :: c# catch multiple exceptions at once 
Csharp :: cefsharp not passing keydown to form 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =