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 :: how to change a string variables value c# 
Csharp :: how to make multiplayer game in unity 
Csharp :: C# removing the last value of an array 
Csharp :: how to make a car in unity 
Csharp :: c# list to string join 
Csharp :: convert string to int and read it 
Csharp :: c# foreach dictionary 
Csharp :: unity keycode for f 
Csharp :: how to make an object move in unity 
Csharp :: c# create object with properties 
Csharp :: how to make a custom cursor in windows forms c# 
Csharp :: c# list to array 
Csharp :: Unity Rigidbody how to set zero momentum 
Csharp :: c# convert split to list 
Csharp :: unity camera follow player 3d smooth 
Csharp :: how to make unity build to not be full screen 
Csharp :: unit test throw exception c# xunit 
Csharp :: blazor swagger setup 
Csharp :: c# string tob64 
Csharp :: c# get type of object 
Csharp :: c# move files from one folder to another 
Csharp :: how to get integer value from textbox in c# 
Csharp :: wpf button 
Csharp :: httpcontext.current.session null c# in class library 
Csharp :: unity get parent object 
Csharp :: HOW TO RETURN CELL VALUE FROM EXCEL IN C# 
Csharp :: shorthand if c# 
Csharp :: ef rollback migration 
Csharp :: relative path c# 
Csharp :: how to make a enter in C# string 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =