How can I convert int
to int[]
and byte[]
to byte[][]
.
I need to retrieve a list of data from database. I will store in the int[]
and byte[][]
.
How can I convert int
to int[]
and byte[]
to byte[][]
.
I need to retrieve a list of data from database. I will store in the int[]
and byte[][]
.
There is no need to convert it. If you want to store a int
into a int[]
you have to create a new array and put it in the first possition.
Same with byte[]
int i = 1;
int[] i2 = new int[] { i };
byte[] b2 = new byte[] { 1 };
byte[][] b3 = new byte[][] { b2 };
It depends on what you want to store?
int
and byte
store just 1 number or one byte.
int[]
and byte[]
are 1 dimensional arrays. Hence they store multiple int
, and byte
objects.
Example:
int[] a = new int[]{1,2,3,4,5};
int[][]
and byte[][]
are 2 dimensional arrays. You can think of them that they store multiple int[]
and byte[]
arrays.
Example:
int[,] a = new int[,] {{1,2}, {3,4}, {5,6}, {7,8}};
Think of it as having 2 rows:
{1,3,5,7}
{2,4,6,8}