Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reading from an SystemArray into an ArrayList???

Posted on 2003-11-07
5
Medium Priority
?
382 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
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

885 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