0

i want to convert to c# the code from url below to vb.net for learning. i haven't learnt c# yet. http://divyen.wordpress.com/2012/06/13/html5-developing-websocket-server-using-c-sharp-dot-net/

i had converted almost all the sources code to VB.Net with converter, the converted sources code have 1 bug Overload resolution failed because no accessible 'Aggregate' accepts this number of arguments.

c# code

public UInt64 Length  
{  
get  
{  
return Payload.Aggregate    <ArraySegment<byte>, ulong>(0, (current, seg) => current +    Convert.ToUInt64(seg.Count));  
}  
}

converted VB.Net code

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  

may i know the equivalent code in VB.Net?

4

3 Answers 3

1

Try this:

Public ReadOnly Property Length() As UInt64
Get
Return Payload.Aggregate(0, Function(current, seg) current + Convert.ToUInt64(seg.Count))
End Get
End Property
Sign up to request clarification or add additional context in comments.

1 Comment

Great answer - this is a tough one to spot sometimes - the reason is that VB has problems with including the generic specifier on Enumerable extension method calls. It's usually best just to leave it off (as you did).
0

Should you insert an Of keyword before ULong

Return Payload.Aggregate(Of ArraySegment(Of Byte), Of ULong)(0, Function(current, seg) current + Convert.ToUInt64(seg.Count))

1 Comment

it show another error when i add of in frond of the ULong. Keyword does not name a type.
0

In advance,use this to convert your code :

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

1 Comment

Note that this converter does not remove the generic specifier, which you have to remove in this case (see coder's answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.