using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
// Sample collection of items
List<int> items = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
// List of values you want to check against
List<int> valuesToCheck = new List<int> { 2, 5, 8 };
// Use LINQ to filter items based on the valuesToCheck list
var filteredItems = items.Where(item => valuesToCheck.Contains(item));
// Display the filtered items
foreach (var item in filteredItems)
{
Console.WriteLine(item);
}
}
}
No comments:
Post a Comment