#region 删除反复字符
string s = “sdfffffsrlkjesgljfdg03940864e5=_0R9DTGR98YUI\\|||’\\???fdf///”;
Response.Write(“<br/>String:” + s + “<br/>Result:”);
IEnumerable<char> distinctList = s.Distinct();
foreach (char a in distinctList)
{
Response.Write(a.ToString());
}
//使用移除法
for (int i = 0; i < s.Length; i++)
{
while (s.IndexOf(s.Substring(i, 1)) != s.LastIndexOf(s.Substring(i, 1)))
{
s = s.Remove(s.LastIndexOf(s.Substring(i, 1)), 1);
}
}
Response.Write(“<hr/>Result:” + s);
#endregion
但愿本文所述对大家的C#措施设计有所辅佐。
除声明外,跑步客文章均为原创,转载请以链接形式标明本文地点
本文地点:
,