find in list c# code example
Example 1: find a value in list of objects in c#
var item = TextPool.FirstOrDefault(o => o.Name == "test");
if (item != null)
item.value = "Value";
Example 2: c# find element by condition
int[] plantHeights = { 3, 6, 4, 1, 6, 8 };
int firstHeight = Array.Find(plantHeights, height => height>5);
Example 3: find value in object c#
var item = TextPool.FirstOrDefault(o => o.Name == "test");
if (item != null)
item.value = "Value";
Example 4: c# find element in list of list
var element = (from sublist in userList
from item in sublist
where item.uniqueidentifier == someid
select item).FirstOrDefault();
Example 5: how to locate a specific element in a list c#
List<int> intList = new List<int>();
int x = List[7];