开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜