DataTableのAddメソッドには、オブジェクト配列を使用してテーブルにデータを追加するオーバーロードが含まれています。オブジェクト[]を使用してデータテーブルにデータを追加できませんか?
私はループバックしてDataTableに挿入できる配列の配列を持っていたいと思います。以下のコードは、4000の配列を作成し、外側の配列(ContiguousTradeMem)の0番目の要素に4つの "列"の配列を配置します。
しかし、私がtestObjectにあったすべてのデータの下の最後の行をデバッグすると(キャッシュ内のContiguousTradeMem [])、DataTable()にコピーされません。
//The "array" which we wish to insert into the DataTable
object[] testObject = new object[4];
//Inserts some test data
for (int m = 0; m < 4; m++)
{
testObject[m] = "test";
}
//A test DataTable
DataTable test = new DataTable();
test.Columns.Add("Col1");
test.Columns.Add("Col2");
test.Columns.Add("Col3");
test.Columns.Add("Col4");
//Put the test "array" into the cache
ContiguousTradeMem[0] = testObject; //The data of testObject is fine here
//Write the cache element to the DataTable
test.Rows.Add(ContiguousTradeMem[0]); //The data is not fine in test.Rows
私は4列のテーブルに4行(配列)を追加しようとしていると思います。 – Marshal
あなたは47の質問があり、答えは66%しか受け入れられません。あなたを助ける人々が好きではありませんか? –