1

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This answer has the correct translation, but I'll add that "Let the compiler figure it out" is fine, as long as you really mean the compiler (Option Infer), and not the runtime (Option Strict Off).
@JoelCoehoorn - Good point. I always have Option Infer On and Option Strict On when working in VB.NET. I would hope everyone would, but you're probably right that not everyone does.
0

_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.

Comments

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.