Link to home
Start Free TrialLog in
Avatar of swordoftruth
swordoftruth

asked on

Reading from an SystemArray into an ArrayList???

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!!
Avatar of purpleblob
purpleblob

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
ASKER CERTIFIED SOLUTION
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Here is the code you should be using


 allBytes.Add(BuffBytes[0]);