Split value according to deliminitor
I have one field as like route the data inside as like(hyd-bang-hyd) i need the result it into two row in first row from is hyd to is bang and 2nd row from is bang and to hyd .the data is not specfic length it may be 4 as like (hyd-pune-mumbai-hyd)this case it should be 3 rows.from hyd to pune in first row and 2nd row from pune to mumbai and 3rd row from mumbai and to hyd
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Joginder BangerRank #360 · 7K reputationPosted Nov 10, 2014, 10:39 PM EST
static void Main(string[] args)
{
bool t=true;
string ss = "hyd-bang-hyd";
string[] temp = ss.Split('-');
string holdvalue=string.Empty;
string holdanother = string.Empty;
for (int i = 0; i < temp.Length; i++)
{
if (t)
{
holdvalue = temp[i];
t = false;
}
else
{
holdvalue += temp[i];
holdanother = holdvalue;
holdvalue = "";
t = true;
}
if (i == temp.Length-1)
{
holdvalue += temp[0];
}
}
}
Joginder BangerRank #360 · 7K reputationPosted Nov 10, 2014, 10:41 PM EST