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 HorvatRank #792 · 2.9K reputationPosted Jul 31, 2011, 11:57 PM EDT
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
Sasikumar S29 reputationPosted Aug 1, 2011, 12:22 AM EDT
Zoran HorvatRank #792 · 2.9K reputationPosted Aug 1, 2011, 12:23 AM EDT
Thanks,
Zoran