ToList().ForEach in Linq

后端 未结 8 899
攒了一身酷
攒了一身酷 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:43

    employees.ToList().ForEach(
         emp=>
         {
              collection.AddRange(emp.Departments);
              emp.Departments.ToList().ForEach(u=>u.SomeProperty = null);
         });
    

提交回复
热议问题