简体   繁体   English

C#到VB.net字节转换

[英]C# to VB.net Byte Conversions

I'm trying to use some code from the Opus project in VB.net, it was originally written for C, but I am integrating it into another application... 我正在尝试使用VB.net中Opus项目中的一些代码,该代码最初是为C编写的,但是我正在将其集成到另一个应用程序中...

    byte[] _notEncodedBuffer = new byte[0];

    byte[] soundBuffer = new byte[e.BytesRecorded + _notEncodedBuffer.Length];

I'm not sure how these should be translated into VB.net, I have translated all the code but this and am getting good results, just not entirely sure on these, had all kinds of errors with my attempts, including Identifier expected, Bracket identifier missing etc! 我不确定如何将它们翻译成VB.net,我已经翻译了所有代码,但都取得了很好的结果,只是不确定这些错误,尝试中遇到了各种错误,包括预期的标识符,括号标识符缺失等! :( :(

    Dim wavNEB As Byte() = New Byte [0]

    Dim wavSnd As Byte() = New Byte [e.BytesRecorded + wavNEB.Length]

That was my last attempt, but no cigar! 那是我最后的尝试,但没有雪茄!

Any help much appreciated, I rarely have to break VB or C out so it's not a strong point... 非常感谢任何帮助,我很少需要中断VB或C,所以这不是重点。

In VB.NET, the syntax 在VB.NET中,语法

Dim ArrayName(N) As ArrayType

is equivalent to the C# code: 等效于C#代码:

ArrayType[] ArrayName = new ArrayType[N+1];

Additionally, if ArrayName has been declared as ArrayType , the executable statement 此外,如果ArrayName已声明为ArrayTypeArrayName执行语句

ReDim ArrayName(N)

would be equivalent to the C# code 相当于C#代码

ArrayName = new ArrayType[N+1];

Additionally, VB.NET offers the syntax 此外,VB.NET提供了语法

ReDim Preserve ArrayName(N)

as a means of replacing ArrayName with a reference to a new array of size N+1 whose contents are pre-loaded with those of the old array. 作为用对大小为N + 1的新数组的引用替换ArrayName一种方法,该数组的内容已预加载旧数组的内容。

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

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