Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reading from an SystemArray into an ArrayList???

Posted on 2003-11-07
5
Medium Priority
?
375 Views
Last Modified: 2010-04-16
HI im trying to read from an array into an arraylist but it keeps on throwing an outofbounds exception,

Numbytes= 1
BufBytes=1
byte[] BufBytes;
ArrayList allBytes = new ArrayList();

while(count != 0)
                        {

                              
                              ReadFile(hComm, BufBytes,NumBytes,ref BytesRead, zero);
                              count = BytesRead;
                              
                        allBytes[i++] = BufBytes[0];
                              
                              }

caN ANYONE HELP!!
0
Comment
Question by:swordoftruth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Expert Comment

by:purpleblob
ID: 9701122
Well the most obvious things is you need to use allBytes.Add - you've created an ArrayList but not actually made any space within the ArrayList

Hope this helps
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 80 total points
ID: 9708115
Also why do you assigne only the first (with index 0) byte to the ArrayList. And why do you assign the BytesRead to the count variable - just use the BytesRead.
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 9718314

Here is the code you should be using


 allBytes.Add(BuffBytes[0]);
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question