我正在尝试修改已经存在的代码。代码是在 2008 年左右开发的,我正在尝试解决排序问题。我也在考虑更改代码,但想先解决这个问题。
ArrayList lineEmpNrs = new ArrayList();
taMibMsftEmpDetails employeeDetails; //taMibMsftEmpDetails is a custom class file
while (!HeaderFile.EndOfStream) //headerfile is employee information text file.
{
headerRow = HeaderFile.ReadLine();
headerFields = headerRow.Split(',');
employeeDetails = BuildLine(headerFields[1],headerFields[2],headerFields[3]);
lineEmpNrs.Add(employeeDetails);
}
private taMibMsftEmpDetails BuildLine(string EmpId, string EmpName, String ExpnsDate)
{
taMibMsftEmpDetails empSlNr = new taMibMsftEmpDetails();
empSlNr.EmployeeId = EmpId;
empSlNr.EmployeeName = EmpName;
empSlNr.ExpenseDate = ExpnsDate;
return empSlNr;
}
头文件包含员工费用详细信息。empID 是这里的关键,headerFile 可以包含“n”行具有相同 EmpID 的行,这些行以随机顺序出现在文件中。
我使用 lineEmpNrs 来构建基于 EmpID 的其他一些信息。所以我想根据 EmpID 对 lineEmpNrs 进行排序。我尝试了常规的排序方法,但没有奏效。
请建议。