我想将c#中的代码从下面的url转换为vb.net进行学习。我还没学过c#。 http://divyen.wordpress.com/2012/06/13/html5-developing-websocket-server-using-c-sharp-dot-net/
我用转换器将几乎所有的源代码转换为VB.Net,转换后的源代码有1个bug 重载解析失败,因为没有可访问的'Aggregate'接受此数量的参数。
c#code
public UInt64 Length
{
get
{
return Payload.Aggregate <ArraySegment<byte>, ulong>(0, (current, seg) => current + Convert.ToUInt64(seg.Count));
}
}
转换后的VB.Net代码
Public ReadOnly Property Length() As UInt64
Get
Return Payload.Aggregate(Of ArraySegment(Of Byte), ULong)(0, Function(current, seg) current + Convert.ToUInt64(seg.Count))
End Get
End Property
我可能知道VB.Net中的等效代码吗?
答案 0 :(得分:1)
试试这个:
Public ReadOnly Property Length() As UInt64
Get
Return Payload.Aggregate(0, Function(current, seg) current + Convert.ToUInt64(seg.Count))
End Get
End Property
答案 1 :(得分:0)
您应该在ULong
之前插入Of
关键字吗?
Return Payload.Aggregate(Of ArraySegment(Of Byte), Of ULong)(0, Function(current, seg) current + Convert.ToUInt64(seg.Count))
答案 2 :(得分:0)