How to remove comma separated value from a string?

后端 未结 10 1887
你的背包
你的背包 2021-01-03 00:13

I want to remove a comma separated value from the string..

suppose I have a string like this

string x=\"r, v, l, m\"

and i want to

10条回答
  •  暖寄归人
    2021-01-03 00:45

    Its just single line of code in many ways, two of them are below:

    string x = "r,v,l,m";
    string NewX = String.Join(",", from i in x.Split(',') where  i != String.Empty && i != "v" select i);
    
    OR
    
    string NewX = String.Join(",", x.Split(',').Select(i => i.Trim()).Where(i => i != String.Empty && i != "v"));
    

提交回复
热议问题