ToList().ForEach in Linq

后端 未结 8 790
攒了一身酷
攒了一身酷 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 10:01

    You can use Array.ForEach()

    Array.ForEach(employees, employee => {
       Array.ForEach(employee.Departments, department => department.SomeProperty = null);
       Collection.AddRange(employee.Departments);
    });
    

提交回复
热议问题