Answers for "update value in list c#"

C#
10

how to add a value to a list in python

myList = [apples, grapes]
fruit = input()#this takes user input on what they want to add to the list
myList.append(fruit)
#myList is now [apples, grapes, and whatever the user put for their input]
Posted by: Guest on April-19-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#

list = list.Where(c=>c.Name == "height")
        .Select( new t(){Name = c.Name, Value = 30})
        .Union(list.Where(c=> c.Name != "height"))
        .ToList();
Posted by: Guest on October-25-2021
0

update value in list c#

list.Where(w => w.Name == "height").ToList().ForEach(s => s.Value = 30);
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
0

update value in list c#

foreach (var mc in list.Where(x => x.Name == "height"))  
     mc.Value = 30;
Posted by: Guest on October-25-2021

C# Answers by Framework

Browse Popular Code Answers by Language