-
Array List Problem
Ok, from what I understand there is no way to resize an array so I'm using an array List.
The problem in my code is that in the last line it says "Cannot implicitly convert type 'object' to 'byte'"
Code:
ArrayList bufferBytes = new ArrayList();
byte tmpByteN;
byte tmpByte;
tmpByteN = BRN.ReadByte();
bufferBytes.Add(tmpByteN);
tmpByte = bufferBytes[0];
Thanks!
-
Try:
Code:
tmpByte = (byte)bufferBytes[0];
-
To explain it further, an arraylist only holds 'Object' types. This is good because you can put anything that derives from Object into the arraylist (which is pretty much everything). Now, when you go to get the item back out, it comes back out as an Object. You specificly have to cast the object to the type that you want to use.