我有一个员工集合,我想以这样一种方式进行过滤,即仅应过滤前 2 列,并应附加第三列值,最终结果应位于单行中
以下是我的代码
List<Employe> Employeecollection = new List<Employe>();
Employeecollection.Add(new Employe("Employee1", "Dept1","Language1"));
Employeecollection.Add(new Employe("Employee2", "Dept2", "Language2"));
Employeecollection.Add(new Employe("Employee3", "Dept3", "Language3"));
Employeecollection.Add(new Employe("Employee3", "Dept3", "Language3"));
Employeecollection.Add(new Employe("Employee1", "Dept1", "Language2"));
foreach (Employe item in Employeecollection.GroupBy(x => new { fName = x.EmpName, lName = x.EmpDept, mName = x.KnownLanguages }).Select(g => g.First()))
{
Console.WriteLine(item.EmpName + " " + item.EmpDept + " " + item.KnownLanguages);
}
但我想显示如下结果
员工 1 部门 1 语言 1、语言 2 员工 2 部门 2 语言 2 员工 3 部门 3 语言 3