有没有人知道如何通过if语句检测字符串中的特殊字符?
我需要输出看起来像这样:
Enter Name: Johnson!
INVALID INPUT TRY AGAIN.
Enter Name: Johnson
ACCEPTED INPUT.
有没有办法只使用using.System?
答案 0 :(得分:0)
由于你的问题不是很明确,
试试这个,如果你想检查字符串input
var specialChars = new[] {"!", ":", ",", "/", "1"}; //add some or more characters or numbers as into this string array
var result = specialChars.Any(input.Contains)