Solved

Reading from an SystemArray into an ArrayList???

Posted on 2003-11-07
5
324 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
5 Comments
 
LVL 6

Expert Comment

by:purpleblob
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
0
 
LVL 20

Accepted Solution

by:
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.
0
 
LVL 22

Expert Comment

by:_TAD_
Comment Utility

Here is the code you should be using


 allBytes.Add(BuffBytes[0]);
0

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 (https://www.paessler.com/prtg). 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