Assume that we have a list like PL = { P1, 0, 10, P2, 5, 20 } and we need
to modify it a datatable likeProcessName ArrivalTime CpuTimeP1
0 10P2 5 20The series of slight (row
count) is dynamic. And we have attempted sth like this: stable
DataTable CreateDataTable() { int j = 0; List PL =
CreateProcessList(); DataTable DT = new DataTable(); for
(int i = 0; i < PL.Count - 2; i += 3) { DataRow
ProcessRow = DT.NewRow(); DT.Rows[j][0] = PL[i].ToString();
DT.Rows[j][1] = Convert.ToInt32(PL[i + 1]);
DT.Rows[j][2] = Convert.ToInt32(PL[i + 2]); j++; }
DT.Columns.Add("Header", typeof(string)); DT.Columns[0].ColumnName
= "ProcessName"; DT.Columns[1].ColumnName = "ArrivalTime";
DT.Columns[2].ColumnName = "CpuTime"; relapse DT; }It does not
work (Says that there is no quarrel during position 0). Thanks for ideas.
No comments:
Post a Comment