Answers for "Filter list contents with predicate (anonymous method)"

C#
0

Filter list contents with predicate (anonymous method)

using System;
using System.Collections.Generic;

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

Predicate<int> isPositive = delegate(int val) { return val > 0; };
var filtered = data.FindAll(isPositive);

Console.WriteLine(string.Join(",", filtered));
Posted by: Guest on October-13-2021

C# Answers by Framework

Browse Popular Code Answers by Language