简体   繁体   中英

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

    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! :(

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

In VB.NET, the syntax

Dim ArrayName(N) As ArrayType

is equivalent to the C# code:

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

Additionally, if ArrayName has been declared as ArrayType , the executable statement

ReDim ArrayName(N)

would be equivalent to the C# code

ArrayName = new ArrayType[N+1];

Additionally, VB.NET offers the syntax

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.

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