Split a string using two Separators in C# .Net

Last Reply on Mar 18, 2015 02:56 AM By Mudassar

Posted on Mar 18, 2015 02:53 AM

hi all

i have some string data like

String str= Samsung=1,Appele=2,Nokia=3,me=4,

and want it string str1=1,2,3,4;

i want to cut all data but remain value between = and ,

like Samsung=1, and replace with 1

Posted on Mar 18, 2015 02:56 AM Modified on on Mar 18, 2015 04:56 AM

This way

string str= "Samsung=1,Appele=2,Nokia=3,me=4";
string nos = "";
foreach(string s in str.Split(','))
{
    nos += s.Split('=')[1] + ",";
}