Hey to all.
Just getting back into learning C#, and i've hit this problem.
What it currently does it bring up a message box showing the following:
I thought this was quite odd, as I set this:
Even though the array is starting at 0, so I would have thought the max value was 3
Anyway, here is the code if anyone has the time to help with this one.
Regards,
Rich
Just getting back into learning C#, and i've hit this problem.
What it currently does it bring up a message box showing the following:
Then it says this:i is currently 0
i is currently 0
i is currently 0
i is currently 0
i is currently 1
i is currently 1
i is currently 1
i is currently 1
i is currently 2
i is currently 2
i is currently 2
i is currently 2
i is currently 3
i is currently 3
i is currently 3
i is currently 3
i is currently 4
i is currently 4
i is currently 4
i is currently 4
and points to this line:IndexOutOfRangeException was unhandled
Code:
userdetails[i] = reader.Value;
Code:
userdetails = new string[4];

Anyway, here is the code if anyone has the time to help with this one.
Code:
public messenger()
{
InitializeComponent();
String URLString = "http://www.routehiker.org.uk/api/help/userdetails.php";
XmlTextReader reader = new XmlTextReader(URLString);
string [] userdetails;
userdetails = new string[4];
int i = 0;
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
userdetails[i] = reader.Value;
i++;
break;
}
MessageBox.Show("i is currently " + i);
}
Form Other = new responses();
Other.ShowDialog();
}
Regards,
Rich
Last edited: