View Single Post
Old Mar 31st, 2008, 5:13 AM   #1
csrocker101
Programmer
 
Join Date: Dec 2006
Posts: 47
Rep Power: 0 csrocker101 is on a distinguished road
Help Indexing ArrayList

Hey everyone I have made an arraylist that takes a stream of information from a string I have made that contains some IP addresses. However I am having a problem assigning the information correctly to my ArrayList. Each IP address is approxiamtely 13 characters long. Here is my code..

string IPAdressesofSystems = service.GetNearbySystems(host);
            ArrayList newList = new ArrayList();

            for (int i = 0; i < IPAdressesofSystems.Length; i++)
            {
                newList.Add(IPAdressesofSystems.Substring(i, 13));
            }

I am well aware it's because of the "i" index I am using in my Substring method is starting at the next incremented index. For example it starts out doing "index[0] = 150.542.234.23 index[1] = 45.543.245.21 index[2] = 4.342.233.29..etc.." because the i is incrementing by one which is making the starting index go up by one everytime. How would I make it so it records all 13 characters of Each IP adress?
csrocker101 is offline   Reply With Quote