Answers for "c# linq in list"

C#
2

linq where in list

var allowedStatus = new[]{ "A", "B", "C" };
var filteredOrders = orders.Order.Where(o => allowedStatus.Contains(o.StatusCode));
Posted by: Guest on November-19-2020
-1

linq from list c#

// Single
string search = "testSearch";
 List<string> list = new List<string>(); // Need to create a string list 
 string result = list.Single(s => s == search);

// Find all where meets the criteria
IEnumerable<string> results = list.Where(s => s == search);
// Select first one
string result = list.First(s => s == search);
Posted by: Guest on July-11-2021

C# Answers by Framework

Browse Popular Code Answers by Language