Fem*_*ref 34
要么只是将其替换掉:
input.Replace("&C=D", "");
Run Code Online (Sandbox Code Playgroud)
或者使用上一个问题中的一个解决方案,将其从数据结构中删除并重新连接在一起.
使用我的代码:
var input = "A=B&C=D&E=F";
var output = input
.Split(new string[] {"&"}, StringSplitOptions.RemoveEmptyEntries)
.Select(s => s.Split('=', 2))
.ToDictionary(d => d[0], d => d[1]);
output.Remove("C");
output.Select(kvp => kvp.Key + "=" + kvp.Value)
.Aggregate("", (s, t) => s + t + "&").TrimRight("&");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64983 次 |
| 最近记录: |