ToList().ForEach in Linq

后端 未结 8 877
攒了一身酷
攒了一身酷 2020-12-04 09:13

I am new to Linq.

I want to set two values in foreach statement like this

My actual code is this

foreach (Employee emp in employees         


        
8条回答
  •  时光取名叫无心
    2020-12-04 09:56

    employees.ToList().Foreach(u=> { u.SomeProperty = null; u.OtherProperty = null; });
    

    Notice that I used semicolons after each set statement that is -->

    u.SomeProperty = null;
    u.OtherProperty = null;
    

    I hope this will definitely solve your problem.

提交回复
热议问题