How to remove comma separated value from a string?

后端 未结 10 1890
你的背包
你的背包 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:49

    Just do something like:

    List Items = x.Split(",").Select(i => i.Trim()).Where(i => i != string.Empty).ToList(); //Split them all and remove spaces
    Items.Remove("v"); //or whichever you want
    string NewX = String.Join(", ", Items.ToArray());
    

提交回复
热议问题