Answers for "Filter list contents with predicate"

C#
0

Filter list contents with predicate

using System;
using System.Collections.Generic;

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

var predicate = new Predicate<int>(isPositive);
var filtered = data.FindAll(predicate);

Console.WriteLine(string.Join(",", filtered));

bool isPositive(int val)
{
    return val > 0;
}
Posted by: Guest on October-13-2021

Code answers related to "Filter list contents with predicate"

C# Answers by Framework

Browse Popular Code Answers by Language