Stuart M Stuart M - 6 months ago 31
Vb.net 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.

Consider

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

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.