简体   繁体   English

C#字节数组转换为VB.NET

[英]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. 根据我的上一个问题,我从Opus项目中借用一些代码来集成到VB.NET软件中。

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... 类型'字节的1维数组'的值不能转换为'整数'错误...

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#: 当然你可以直接翻译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. _encoder.Encode()是作业的右侧。 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. 您在VB示例中使用它的方式是作为数组维度:整数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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