- Регистрация
- 21.08.2013
- Сообщения
- 249
- Благодарностей
- 12
- Баллы
- 18
I have the following code that cleans the text for any special chars and I would like to use it in my c# code block
I have tried adding this into my c# code block as it is and I get errors: CS1513, CS1519, CS1003.
Have also tried to add that code into the OwnCodeUsings>Shared code and then execute RemoveSpecialCharacters(myString) but this throws RemoveSpecialCharacters does not exist in the current context.
Код:
public static string RemoveSpecialCharacters(string str) {
StringBuilder sb = new StringBuilder();
foreach (char c in str) {
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '.' || c == '_') {
sb.Append(c);
}
}
return sb.ToString();
}
Have also tried to add that code into the OwnCodeUsings>Shared code and then execute RemoveSpecialCharacters(myString) but this throws RemoveSpecialCharacters does not exist in the current context.