public static string ReplaceSpecialCharecters(string stringtoreplce, string charwithreplace)
{
string str = string.Empty;
if (stringtoreplce.Contains(" "))
stringtoreplce = stringtoreplce.Trim().Replace(" ", "-");
if (stringtoreplce.Contains(enDash))
stringtoreplce = stringtoreplce.Replace(enDash, '-');
if (stringtoreplce.Contains('~'))
stringtoreplce = stringtoreplce.Replace('~', '-');
if (stringtoreplce.Contains('`'))
stringtoreplce = stringtoreplce.Replace('`', '-');
if (stringtoreplce.Contains('!'))
stringtoreplce = stringtoreplce.Replace('!', '-');
if (stringtoreplce.Contains('@'))
stringtoreplce = stringtoreplce.Replace('@', '-');
if (stringtoreplce.Contains('#'))
stringtoreplce = stringtoreplce.Replace('#', '-');
if (stringtoreplce.Contains('$'))
stringtoreplce = stringtoreplce.Replace('$', '-');
if (stringtoreplce.Contains('%'))
stringtoreplce = stringtoreplce.Replace('%', '-');
if (stringtoreplce.Contains('^'))
stringtoreplce = stringtoreplce.Replace('^', '-');
if (stringtoreplce.Contains('&'))
stringtoreplce = stringtoreplce.Replace('&', '-');
if (stringtoreplce.Contains('*'))
stringtoreplce = stringtoreplce.Replace('*', '-');
if (stringtoreplce.Contains('<'))
stringtoreplce = stringtoreplce.Replace('<', '-');
if (stringtoreplce.Contains('>'))
stringtoreplce = stringtoreplce.Replace('>', '-');
if (stringtoreplce.Contains(','))
stringtoreplce = stringtoreplce.Replace(',', '-');
if (stringtoreplce.Contains('/'))
stringtoreplce = stringtoreplce.Replace('/', '-');
if (stringtoreplce.Contains(';'))
stringtoreplce = stringtoreplce.Replace(';', '-');
if (stringtoreplce.Contains(':'))
stringtoreplce = stringtoreplce.Replace(':', '-');
if (stringtoreplce.Contains('|'))
stringtoreplce = stringtoreplce.Replace('|', '-');
if (stringtoreplce.Contains('\\'))
stringtoreplce = stringtoreplce.Replace('\\', '-');
if (stringtoreplce.Contains('"'))
stringtoreplce = stringtoreplce.Replace('"', '-');
if (stringtoreplce.Contains(rsingleQuote))
stringtoreplce = stringtoreplce.Replace(rsingleQuote, '-');
if (stringtoreplce.Contains('.'))
stringtoreplce = stringtoreplce.Replace('.', '-');
while (stringtoreplce.Contains("--"))
stringtoreplce = stringtoreplce.Replace("--", "-");
return stringtoreplce;
}
{
string str = string.Empty;
if (stringtoreplce.Contains(" "))
stringtoreplce = stringtoreplce.Trim().Replace(" ", "-");
if (stringtoreplce.Contains(enDash))
stringtoreplce = stringtoreplce.Replace(enDash, '-');
if (stringtoreplce.Contains('~'))
stringtoreplce = stringtoreplce.Replace('~', '-');
if (stringtoreplce.Contains('`'))
stringtoreplce = stringtoreplce.Replace('`', '-');
if (stringtoreplce.Contains('!'))
stringtoreplce = stringtoreplce.Replace('!', '-');
if (stringtoreplce.Contains('@'))
stringtoreplce = stringtoreplce.Replace('@', '-');
if (stringtoreplce.Contains('#'))
stringtoreplce = stringtoreplce.Replace('#', '-');
if (stringtoreplce.Contains('$'))
stringtoreplce = stringtoreplce.Replace('$', '-');
if (stringtoreplce.Contains('%'))
stringtoreplce = stringtoreplce.Replace('%', '-');
if (stringtoreplce.Contains('^'))
stringtoreplce = stringtoreplce.Replace('^', '-');
if (stringtoreplce.Contains('&'))
stringtoreplce = stringtoreplce.Replace('&', '-');
if (stringtoreplce.Contains('*'))
stringtoreplce = stringtoreplce.Replace('*', '-');
if (stringtoreplce.Contains('<'))
stringtoreplce = stringtoreplce.Replace('<', '-');
if (stringtoreplce.Contains('>'))
stringtoreplce = stringtoreplce.Replace('>', '-');
if (stringtoreplce.Contains(','))
stringtoreplce = stringtoreplce.Replace(',', '-');
if (stringtoreplce.Contains('/'))
stringtoreplce = stringtoreplce.Replace('/', '-');
if (stringtoreplce.Contains(';'))
stringtoreplce = stringtoreplce.Replace(';', '-');
if (stringtoreplce.Contains(':'))
stringtoreplce = stringtoreplce.Replace(':', '-');
if (stringtoreplce.Contains('|'))
stringtoreplce = stringtoreplce.Replace('|', '-');
if (stringtoreplce.Contains('\\'))
stringtoreplce = stringtoreplce.Replace('\\', '-');
if (stringtoreplce.Contains('"'))
stringtoreplce = stringtoreplce.Replace('"', '-');
if (stringtoreplce.Contains(rsingleQuote))
stringtoreplce = stringtoreplce.Replace(rsingleQuote, '-');
if (stringtoreplce.Contains('.'))
stringtoreplce = stringtoreplce.Replace('.', '-');
while (stringtoreplce.Contains("--"))
stringtoreplce = stringtoreplce.Replace("--", "-");
return stringtoreplce;
}
No comments:
Post a Comment