Hi everyone,

I'm just starting with D and i need a way to declare a byte array
something like:

byte[] arr = [ 0x00, 0xA4, 0x04];

This throws a int[] to byte[] cast error

Tried also these ones

byte[] arr = "\x00\xA4\x04";
byte[] arr = [ '\x00', '\xA4', '\x04'];
byte[] arr = [ u'\x00', u'\xA4', u'\x04'];
byte[] arr = [ b'\x00', b'\xA4', b'\x04'];

I also tried
byte[] arr = [cast(byte) 0x00, cast(byte)0xA4, cast(byte) 0x04];
and this at least compiles

I read the online book and nowhere there is a byte literal mentioned.

Is there another way besides casting to byte?

Thanks in Advance.

Reply via email to