list比较交集
List<int> LstAllStatusCode = new List<int>() { 1, 2, 3, 4, 5 };
List<int> LstQueryedStatusCode = new List<int>();
/*try get other status that the data haven't record in system.*/
foreach (DataRow row in dt.Rows)
{
LstQueryedStatusCode.Add(Convert.ToInt16(row[0]));
}
/*比较交集*/
List<int> LstNeedFill = LstAllStatusCode.Except<int>(LstQueryedStatusCode).ToList();
foreach (int fillCode in LstNeedFill)
{
DataRow newrow = dt.NewRow();
newrow[0] = fillCode;
newrow[0] = 0;
dt.Rows.Add(newrow);
}