简体   繁体   中英

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?

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.

_encoder.Encode() is the right-hand side of an assignment. The left-hand side is a byte array.

The way you are using it in your VB sample is as an array dimensioner: an Integer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM