#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