![]() |
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);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? |
Re: Help Indexing ArrayList
why would you not split your string into the array? I don't know how getnearbysystems populates the string, but it should separate the ip addresses somehow, and you can use that delimiter to split your string into usable array entries
Quote:
I'm not familiar with C#, but in VB it would look something like this: :
This way, it don't matter what the size of each individual string is. The code I posted displays each array element in a new message box. |
Re: Help Indexing ArrayList
I tried to convert this to C# but I don't know enough about it to really do it.
:
I get all kinds of errors about my strings and arrays, but maybe it'll help you out at least a little bit. |
Re: Help Indexing ArrayList
Use this code with your variables.... remember to replace the comma in the split call with your delimiter.
:
|
Re: Help Indexing ArrayList
Or just use i=i+13 in your loop?
If you KNOW each IP is 13 characters, and you don't have a delimiter... |
| All times are GMT -5. The time now is 1:15 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC