Stuart M Stuart M - 1 year ago 114 Question

C# byte array conversion to VB.NET

As per my last question I'm borrowing some code from the Opus project to integrate into VB.NET software.


byte[] buff = _encoder.Encode(segment, segment.Length, out len);

which I've translated to:

Dim buff(wavEnc.Encode(segment, segment.Length, len)) As Byte

It is throwing a:

Value of type '1-dimensional array of Byte' cannot be converted to 'Integer' error...

How can I fix this problem?

Answer Source

Try this:

Dim buff = wavEnc.Encode(segment, segment.Length, len)

Of course you can do a direct translation of the c#:

Dim buff As Byte() = wavEnc.Encode(segment, segment.Length, len)

No need for a type at all - let the compiler figure it out.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download