Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
remove special char c#
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { string str = "$N!il$e&s%h%"; Console.WriteLine(RemoveSpecialChars(str)); } public static string RemoveSpecialChars(string str) { // Create a string array and add the special characters you want to remove string[] chars = new string[] { ",", ".", "/", "!", "@", "#", "$", "%", "^", "&", "*", "'", "\"", ";", "_", "(", ")", ":", "|", "[", "]" }; //Iterate the number of times based on the String array length. for (int i = 0; i < chars.Length; i++) { if (str.Contains(chars[i])) { str = str.Replace(chars[i], ""); } } return str; } } }
run
|
edit
|
history
|
help
0
ss
MyGenerics
Conditional linq operators
Regras Recad grupo
sss
First Test With Coder - 3 digit number into digits
C# Dictionary with Enum Keys And Values
functional program
Events
Access Modifiers