my question is i want to split 2, 1-5.
by using string [] split = PagesId .Split(new Char [] {',' , '-' },
StringSplitOptions.RemoveEmptyEntries); it is showing 2,1,5; but my out put is 2,1,2,3,4,5.
please help me.
Loading
Posted Apr 10, 2014, 7:07 AM
Please try below code
string s = "2, 1-5";
string[] sp = s.Split(',');
string output = sp[0]+",";
sp = sp[1].Split('-');
for (int ind = Convert.ToInt32(sp[0]); ind <= Convert.ToInt32(sp[0]); ind++)
{
output+=ind.ToString()+",";
}
Console.WriteLine(output);
Console.ReadLine();
Please accept as answer, if it helps you
VulpesPosted Apr 10, 2014, 7:07 AM
Try this: