【发布时间】:2018-10-26 10:24:15
【问题描述】:
我使用 converter.telerik.com 转换了这段代码
来自
public Decimal CartTotal()
{
return this.Items.Sum<CartItem>((Func<CartItem, Decimal>) (x => x.Total));
}
收件人
Public Function CartTotal() As Decimal
Return Me.Items.Sum(Of CartItem)(CType((Function(x) x.Total), Func(Of CartItem, Decimal)))
End Function
但是编译器说
重载解析失败,因为没有可访问的“总和”接受这个 类型参数的数量。
【问题讨论】:
-
Where在哪里? -
我的意思是
sum,已经更正了 -
我真的不明白为什么 C# 不只是
return this.Items.Sum(ci => ci.Total);,在这种情况下,VB 将是Return Me.Items.Sum(Function(ci) ci.Total)。 -
C# 代码应该只是
this.Items.Sum(x => x.Total);。不需要其他任何东西。没有明确的类型,没有Func<>语法。看起来有人使用转换器工具将 VB.NET 代码转换为 C# -
@Smith 当我尝试使用converter.telerik 转换您的代码时,它会抛出错误
Specified method is not supported.看看@PanagiotisKanavos 评论
标签: c# vb.net code-conversion