【发布时间】:2014-03-03 12:14:33
【问题描述】:
任何人都可以将此 c# linq 代码转换为 VB 吗?我尝试了 developerfusion,没有成功
DataTable dt = dt1.Copy();
var result = dt
.AsEnumerable()
.Select(r => r.Field<string>(0))
.Select(s => string.Join("",
s.Select((x, i) => x == '0'
? " "
: (i + 1).ToString()))
).ToList();
我尝试的是
Dim dt As DataTable = dt1.Copy()
Dim result = dt.AsEnumerable().[Select](Function(r) r.Field(Of String)(0)).[Select](Function(s) String.Join("", s.[Select](Function(x, i) If(x = "0"c, " ", (i + 1).ToString())))).ToList()
但它显示错误
Data type(s) of the type parameter(s) in extension method 'Public Function Select(Of S)(selector As System.Func(Of String, S)) As System.Data.EnumerableRowCollection(Of S)' defined in 'System.Data.EnumerableRowCollectionExtensions' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
我的数据表只有一列,看起来像 第一行 1000000 对于第二行 0010000 从第三行 0100000 等开始,我想要得到的是用空格替换所有 0,用它的位置编号替换所有 1,即;对于第一行,所需的输出类似于(1000000)。对于第二行(0030000)和第三行(0200000)。像这样
【问题讨论】:
-
didn't work是什么意思?? -
你投了这么多反对票?
-
你能解释一下错误吗?不过对我来说似乎很好!
-
我用我得到的错误更新了我的问题