Hi friends,
While i am trying to parse the string and assign each string into two dimensional array it raising errors. my code shown below
String[][] location =null;
String sIPAddress="Chennai@tamilnadu@india");
int j = 0;
rt.Text = string.Empty;
for (int i = 0; i < sIPAddress.Length; i++)
{
ipvalue = sIPAddress[i].ToString();
locate= getlocate(ipvalue);
String[] str = locate.Split('@');
foreach(string place in str)
{
j = j + 1;
location[i][j] = place;
}
j = 0;
}
error message:
Object reference not set to an instance of an object
is there any solutions to solve this problem..
regards
sasi
Loading
Zoran HorvatPosted Aug 1, 2011, 4:23 AM
Thanks,
Zoran
Sasikumar SPosted Aug 1, 2011, 4:22 AM
Zoran HorvatPosted Aug 1, 2011, 3:57 AM
String[][] location =null;
String sIPAddress="Chennai@tamilnadu@india");
int j = 0;
rt.Text = string.Empty;
location = new string[sIPAddress.Length][]; // Here is allocation of the jagged array
for (int i = 0; i < sIPAddress.Length; i++)
{
ipvalue = sIPAddress[i].ToString();
locate= getlocate(ipvalue);
String[] str = locate.Split('@');
location[i] = new string[str.Length]; // Here is allocation of a row
foreach(string place in str)
{
j = j + 1;
location[i][j] = place;
}
j = 0;
}
Zoran