Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

byte[] to ArrayList?

Could somebody tell me how can I convert byte[] to ArrayList by using C# under Windows Mobile?

Later edit:

  1. this would go like having an ArrayList containing instances of a custom type. This list goes to a database (into a blob) as a byte array (the conversion is done by the database API); What I want is to revert the byte[] to ArrayList;

  2. .NET CF does not provide the BinaryFormatter;

like image 785
thelost Avatar asked Dec 02 '22 07:12

thelost


1 Answers

All arrays inherit off ICollection, so you can just use

ArrayList list = new ArrayList(bytearray);

although I would use the generic List<byte> myself using the same method, as that prevents boxing of each byte value in the array. Although arrays don't staticly inherit off the generic IList for the respective type, the CLR adds relevant implementations to each array instance at runtime (see the Important Note here)

like image 200
thecoop Avatar answered Dec 24 '22 12:12

thecoop