********************Remove ****************
Solution one:
We use a built-in element deduplication method Distinct
string a = "abcabcd"; char[] b = a.ToArray().Distinct().ToArray(); string c = string.Join("", b);
Solution two:
ArrayList alist = new ArrayList(); char[] strs = a.ToArray(); for (int i = 0; i < strs.Length; i++) { if (!alist.Contains(strs[i])) { alist.Add(strs[i]); } }
****************Filter Numeric or Non-Numeric ****************
/// Remove the numbers in the string public static string RemoveNumber( string key) { return Regex.Replace(key, @"\d", ""); } // Remove non-numbers in the string public static string RemoveNotNumber( string key) { return Regex.Replace(key, @"[^\d]*", ""); }