DataTable行列转置

DataTable dtNew = new DataTable();
dtNew.Columns.Add("ColumnName", typeof(string));
for (int i = ; i < dt.Rows.Count; i++)
{
dtNew.Columns.Add("Column" + (i + ).ToString(), typeof(string));
}
foreach (DataColumn dc in dt.Columns)
{
DataRow drNew = dtNew.NewRow();
drNew["ColumnName"] = dc.ColumnName;
for (int i = ; i < dt.Rows.Count; i++)
{
drNew[i + ] = dt.Rows[i][dc].ToString();
}
dtNew.Rows.Add(drNew);
}
上一篇:#iOS问题记录#关于NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9801)


下一篇:linux后台执行./run.py提示python syntax error near unexpected token `('