C#到vb.net的转换

时间:2015-08-26 04:20:10

标签: vb.net

我做了一个C#到VB.net转换,除了1件事以外都经历了。

获得错误"期望结束语"

代码

Dim query = From line In allLines Let data = line.Split(","C)New With { _
        Key .number = data(0), _
        Key .ip = data(1) _
    }

我不确定它不喜欢上面的代码。

原始C#代码

var query = from line in allLines
                        let data = line.Split(',')
                        select new
                        {
                            number = data[0],
                            ip = data[1],
                        };

1 个答案:

答案 0 :(得分:2)

您的VB代码缺少关键字Select。等效的C#代码应为

Dim query = From line In allLines
    Let data = line.Split(","c)
    Select New With {Key .number = data(0), Key .ip = data(1)}