Results 1 to 3 of 3

Thread: Array List Problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2004
    Posts
    26

    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!

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    Try:
    Code:
    tmpByte = (byte)bufferBytes[0];

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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
  •  



Click Here to Expand Forum to Full Width