DataTable dt = new DataTable();
string str;
string[] s = Array.ConvertAll<DataRow, string>(dt.Select(), delegate(DataRow row)
{
return (string)row[""];
});
str = String.Join(",", s);
-1
A
回答
0
你在尋找類似如下:
Dim dt As DataTable = New DataTable()
Dim str As String
Dim s As String() = Array.ConvertAll(Of DataRow, String)(dt.Select(), Function(row As DataRow) DirectCast(row(""), String))
str = String.Join(",", s)
在VB 8.0 (.Net 2.0)
情況下,它不支持匿名方法。要解決的是,使用下面的代碼:
Dim dt As DataTable = New DataTable()
Dim str As String
Dim s As String() = Array.ConvertAll(Of DataRow, String)(dt.Select(), AddressOf ConvertRowToString)
str = String.Join(",", s)
ConvertRowToString
功能:
Function ConvertRowToString(ByVal row As DataRow) As String
Return DirectCast(row(""), String)
End Function
+0
它給語法錯誤「的表達研究例外」的功能關鍵字 – Ramamoorthy 2011-02-23 06:58:29
+0
你使用的是什麼版本的VB/.Net Framework? – decyclone 2011-02-23 06:59:46
+0
你爲什麼使用'CType'? – 2011-02-23 07:05:23
相關問題
- 1. 轉換vb.net代碼轉換爲C#.NET
- 2. 如何將c#代碼轉換爲vb.net
- 3. 將vb.net代碼片段轉換爲c#
- 4. 將C#代碼轉換爲vb.net
- 5. 將VB.NET代碼轉換爲C#
- 6. 在C#轉換代碼段VB.Net
- 7. Foreach循環VB.Net到C#代碼轉換
- 8. 轉換數據集代碼VB.net到C#
- 9. C#到VB.NET代碼轉換器
- 10. 通C#變量轉換爲JavaScript代碼
- 11. VB.NET轉換爲C#
- 12. 將1行PHP代碼轉換爲VB.NET
- 13. 代碼轉換到vb.net
- 14. 需要將C#代碼轉換爲VB.NET for Silverlight「導出爲CSV」
- 15. 將JavaScript代碼轉換爲C代碼
- 16. 將PHP代碼轉換爲C#代碼
- 17. 將Java代碼轉換爲C#代碼
- 18. 將僞代碼轉換爲C#代碼
- 19. 轉換Matlab代碼爲C代碼
- 20. 如何這個asp.net MVC代碼從C#轉換爲vb.net
- 21. 如何某些C#代碼轉換爲VB.NET
- 22. NHibernate實體代碼從#C轉換爲VB.Net
- 23. 錯誤時試圖C#代碼轉換爲VB.Net
- 24. 將C#6語法的簡單代碼轉換爲Vb.Net
- 25. 將C#中的代碼片段轉換爲VB.NET
- 26. 將最小起訂設置代碼轉換爲vb.net從c#
- 27. 將代碼片段從VB.NET轉換爲C#
- 28. 問題在代碼形式vb.net轉換爲C#
- 29. 需要一些幫助將VB.NET代碼轉換爲C#
- 30. 解釋一塊C#代碼並轉換爲VB.NET
問題是這麼好措辭,我無語... – Mehrdad 2011-02-23 06:48:02