|
-
Nov 26th, 2004, 01:42 AM
#1
Thread Starter
Junior Member
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!
-
Nov 26th, 2004, 04:12 AM
#2
Try:
Code:
tmpByte = (byte)bufferBytes[0];
-
Nov 26th, 2004, 02:40 PM
#3
PowerPoster
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|