Solved

Reading from an SystemArray into an ArrayList???

Posted on 2003-11-07
5
350 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 20 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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