我有兩個ID列表,兩個列表都有相同數量的項目,它們具有相同的ID,它們只是不按順序,例如:if語句...如果沒有這個ID,請稍後再試
List 1 - (194, 195, 196, 197, 198, 199, 200)
List 2 - (194, 200, 198, 195, 197, 196, 199)
我有一個聲明,如果compairs這些ID:
if (cells[i].scheduleTaskID == taskid)
這非常適用於第一個ID,因爲它們匹配(194),但其他ID不匹配,有沒有走,我可以說,如果taskid不匹配單元格[i] .scheduleTaskID稍後嘗試任務ID?
這裏是額外的代碼:
int taskid = reader.GetInt32(0); (gets taskid from database)
List<CellModel> cells
,這是CellModel:
public class CellModel
{
public uint scheduleTaskID { get; set; }
public string task { get; set; }
public string baselineDate { get; set; }
public string scheduledDate { get; set; }
public string actualDate { get; set; }
public string finishedDate { get; set; }
public bool selected { get; set; }
public override string ToString()
{
return scheduleTaskID.ToString();
}
}
也許'SortedList'會是一個更好的選擇嗎? – 2014-10-29 17:50:45
您可以對列表或嵌套循環進行排序! – mybirthname 2014-10-29 17:51:31
你到底在做什麼?什麼目的。你是否試圖找到List1中不在List2中的項目?或者是什麼? – 2014-10-29 18:15:25