c#代码到vb.net转换问题

时间:2013-09-28 07:51:02

标签: c# asp.net vb.net

我想将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#c​​ode

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中的等效代码吗?

3 个答案:

答案 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)

事先使用它来转换你的代码:

http://www.developerfusion.com/tools/convert/csharp-to-vb