任何一个可以转换这个C#LINQ代码到VB?我想developerfusion,didnt工作转换LINQ C#到VB.Net
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.
我的数据表只有单列,看起来像第一行的第二排0010000 第三排0100000等等,我想得到的是用空白区和全部1代替它的位置编号即所有0;对于第一行,期望的输出像(1000000)。第二行(0030000)和第三行(0200000)。这样
指定数据类型(S)您'没有work'意味着什么? –
显示语法错误 – Cronaldo
这些太多了倒票? – Cronaldo