public static bool HasSpecialChar(this string s, char ignore) { var invalids = CharExtensions.GetSpecialChars(); foreach (var item in s) { if (item == ignore) { continue; } if (invalids.Where(a => a == item).Count() > 0) { return(true); } } return(false); }
public static string RemoveSpecialChar(this string s, char[] ignore) { var invalids = CharExtensions.GetSpecialChars(); string ret = s; foreach (var item in s) { if (ignore.Contains(item)) { continue; } if (invalids.Where(a => a == item).Count() > 0) { ret = ret.Replace(item.ToString(), string.Empty); } } return(ret.Trim()); }