Convert Byte Array to String


I have a structure with a byte array defined: MyByteArray(12) as Byte
The content of those bytes are char send over UDP from a application written in C/C++

How can I convert this array of bytes to a string? I do a for-loop but this doesn’t seems to be elegant (and I have a lot of byte arrays).

[code] Dim myByteArray(12) as Byte
Dim myString As string


myString = ??[/code]

Structures have a stringvalue proeprty, I think to read whole data in a block as string.

Thank you for the answer.
If I understand you, I should convert the whole structure to a string. But my structure consist a lot of integers, byte arrays (=strings), doubles and so on. If I convert the whole structure to a string I have to split it up by hand after the conversion. Then I don’t need the structure anyway and can do that directly.

But now I have read the manual a little bit better and found out I can define strings (with a fixed length) in a structure with:
fieldName As String * size

So that solved my problem. Thank you anyway.

Coming from C and C# there is a lot new different thinking with RealBasic :slight_smile:

Please check:

you can have fields in the structure which are strings of fixed size.
But you can also copy the whole structure as string for writing to a file for example.