C# code convert into VB.Net (Generic)
DataTable dt = new Dat开发者_如何学编程aTable();
string str;
string[] s = Array.ConvertAll<DataRow, string>(dt.Select(), delegate(DataRow row)
{
return (string)row[""];
});
str = String.Join(",", s);
Are you looking for something like following:
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)
In case of VB 8.0 (.Net 2.0)
, it does not support anonymous methods. To workaround that, use following code:
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:
Function ConvertRowToString(ByVal row As DataRow) As String
Return DirectCast(row(""), String)
End Function
精彩评论