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:
Originally Posted by csrocker101
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.
|
What this code does is what you said. If you use the string.split method to separate your string, it will look for whatever delimiter you specify.
I'm not familiar with C#, but in VB it would look something like this:
Dim str1 As String = "xyz,pbb7,rx78"
Dim str2() As String
str2 = str1.Split(",")
For x As Integer = 0 To str2.Length - 1
MsgBox(str2(x), MsgBoxStyle.Information, "Array")
Next
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.