How to save byte[,]

Hey, easy and not so easy question. How can I save byte[,] in c# ?

I am using currently byte array with x and y values:

public byte[,] block;

block = new byte[12,28];

block[0,0] = 2;

block[1,0] = 1;

block[2,1] = 2;


In normal case I would use:

File.WriteAllBytes(“Name.txt”, byte);

But in this case I kind of need to save 3 values: x, y, value.

Thank you!

just convert your 2D to a 1D, read along a row, then read along the next row etc and save them in one long row! then you could save how long the original row lengths were and read them out with the inverse algorithm, or append a set number of bytes to the end of your array that you can get the original row length from.