ToList().ForEach in Linq

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

    you want this?

        employees.ForEach(emp =>
        {
            collection.AddRange(emp.Departments.Where(dept => { dept.SomeProperty = null; return true; }));
        });
    

提交回复
热议问题