Change some value inside the List

前端 未结 7 1400
甜味超标
甜味超标 2020-12-07 22:23

I have some list (where T is a custom class, and class has some properties). I would like to know how to change one or more values inside of it by using Lambda Expressions,

7条回答
  •  余生分开走
    2020-12-07 22:55

    You could use ForEach, but you have to convert the IEnumerable to a List first.

    list.Where(w => w.Name == "height").ToList().ForEach(s => s.Value = 30);
    

提交回复
热议问题