我想一個DataRow[]
的值返回一個字符串在C#中添加一個DataRow []列的列結果的變量c#
這裏是我的DataTable
:
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("BugDescription", typeof(string));
table.Columns.Add("UnitPrice", typeof(double));
table.Rows.Add(1, "Bug 1", 10.00);
table.Rows.Add(2, "Bug 2", 20.00);
然後創建一個DataRow[]
稱爲result
其存儲行,所述ID = 1:
DataRow[] result = table.Select("ID = 1");
,我想要實現的最後一步是要添加的Bug將值描述爲名爲description
的字符串。
我將如何實現這一目標?
如果你期待一行將返回(因爲你的ID選擇它)爲什麼使用DataRow數組而不是DataRow?我的意思是爲什麼不只是DataRow result = table.Select(「ID = 1」); –
我是新來的整個C#,我只是在網上教程[鏈接](http://www.dotnetperls.com/datatable-選擇),所以我不知道你可以。這樣做會更好嗎? – Win