讓我試着解釋一下 我有兩個列表 1.員工對象列表 2.部門對象列表(其中包含可以工作的員工列表在部門)C#如何將對象添加到列表中有對象列表
我想能夠添加一個員工到列表中的員工列表中的部門。
但我正在逐漸零誤差
int empsize = allemployees.Count;
int Maxdepartment = 0;
foreach (employee employeeitem in allemployees)
{
Maxdepartment = employeeitem.alloweddepartments.Count;
for (int i = 0; i < Maxdepartment; i++)
{
int index = alldepartments.FindIndex(x => x.Name == employeeitem.alloweddepartments[i].ToString());
alldepartments[index].earlyshift.Add(employeeitem);
}
如果我們看到你的工作會更好.. –
告訴我們你的(低效?)解決方案,也許一個的我們知道更好的一個 – Stefan
員工們說他們每天想要開始和結束的時間(例如MondayIn,MondayOut)?你想爲所有員工計算完美的一天,並將他們分配到不同的部門?爲什麼使用float而不是DateTime? – Stefan