0

I would like to have an array of byte arrays.

If I have an array of int, I can set a length of it with this:

var array = new int[12];

But if I try this with byte[], it doesn't work:

var bytesArray = new byte[][12];

How can I define an array of byte arrays?

(In the moment, I try to define this, I don't know the individual length of the single byte arrays.)

2 Answers2

4

new byte[12][], as discussed here: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/arrays/jagged-arrays

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
0

Alternative way var bytesArray = (byte[][])Array.CreateInstance(typeof(byte[]), 12); using Array.CreateInstance.

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197