Answers for "c# update item in list"

C#
1

c# edit element in list

var index = list.FindIndex(c => c.Number == someTextBox.Text);
list[index] = new SomeClass(...);
Posted by: Guest on March-23-2020
0

update value in list c#

var result = list.Select(i => 
   { 
      if (i.Name == "height") i.Value = 30;
      return i; 
   }).ToList();
Posted by: Guest on October-25-2021
0

update value in list c#

public static IEnumerable<MyClass> SetHeights(
    this IEnumerable<MyClass> source, int value)
{
    foreach (var item in source)
    {
       if (item.Name == "height")
       {
           item.Value = value;
       }

       yield return item;
    } 
}

var result = list.SetHeights(30).ToList();
Posted by: Guest on October-25-2021

C# Answers by Framework

Browse Popular Code Answers by Language