I have this piece of code which is calling some functions in a web service. however the original was written in VB and when I have converted it it gives me an error in my c# stating that ‘The name Information does not exist in the current context’ I have checked the VB and it win there either! any thoughts?
Code
try {
Atlas.ah21 oAh21 = new Atlas.ah21();
oAh21.session_id = sessionID;
oAh21.input = txtPostcode.Text;
oAh21.data = "";
Atlas.arrayOfAddress oAddresses = oAtlas.ah21(oAh21);
int x = 0;
int y = 0;
string s = null;
for (x = 0; x <= oAddresses.address.Length - 1; x++)
{
s = "";
for (y = 0; y <= Information.UBound(oAddresses.address(x).LABEL.item); y++)
{
if (s.Length > 0)
{
s = s + ", ";
}
s = s + oAddresses.address(x).LABEL.item(y);
}
lstMatches.Items.Add(s);
}
txtStatus.Text = "Ready. ";
if (oAddresses.address.Length > 1) {
txtStatus.Text = txtStatus.Text + Convert.ToString(oAddresses.address.Length) + " matches found.";
} else {
txtStatus.Text = txtStatus.Text + Convert.ToString(oAddresses.address.Length) + " match found.";
}
} catch {
txtStatus.Text = "Error";
} finally {
btnSearch.Enabled = true;
}
Please excuse the amount of code however i think it necessary in the context of this question.
I don’t really know VB but i think UBound is just returning the length of the collection so you would do
Further to your comment i have realised that address(x) should be address[x]. In c# you only use () for method calls, indexers use []. In VB they both use () i think.