0

Hi - I would like to separate out data as individual pieces.for eg, I have information as

1050 Buckingham Street,,Watertown,C,S06795660<br>737 McKNIGHT RD,,PITTSBURGH,P,S15237351<br>......(lot of data like this format)

And I am trying to get result as

addr1=1050 Buckingham Street
addr2 = null
city=Watertown
state=C
pincode=S06795660

currently I have code

int myIndex=myOutput.IndexOf(",");
  string addr1 = myOutput.Substring(0,myIndex);
  string addr2 = myOutput.Substring(myIndex,myOutput.Length-myIndex);

please help me.Also, Please let me know is there any easy way to fix this. Thanks!

Edited by madhan: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

Since your data is seperated by a delimiter (comma), you can do an array of data.
Then each index of an array will be holding each seperated data like address1, address2, city,..
This way will be faster and easier to sepetate.

So you can do:

string[] dataArray = myOutput.Split(',');
//so you now have all data in the array splitted:
string addr1 = dataArray[0];
string arr2 = dataArray[1];
string city = dataArray[2];
//and so on...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.