Reading from an SystemArray into an ArrayList???

Posted on 2003-11-07
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
byte[] BufBytes;
ArrayList allBytes = new ArrayList();

while(count != 0)

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

Question by:swordoftruth

Expert Comment

Comment Utility
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
LVL 20

Accepted Solution

TheAvenger earned 20 total points
Comment Utility
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.
LVL 22

Expert Comment

Comment Utility

Here is the code you should be using


Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now