简体   繁体   English

检查 char 是否是这些字符之一 !@#%&()-_/.,;':"\\][{}

[英]Check if char is one of these chars !@#%&()-_/.,;':"\][{}

I want to check if the current character in a TextBox in WPF is of !@#%&()-_/.,;':"][{} this type.我想检查 WPF 中 TextBox 中的当前字符是否为 !@#%&()-_/.,;':"][{} 这种类型。

I want to convert all the keyboard into a specific character and so far only those characters are not covered by my code.我想将所有键盘转换为特定字符,到目前为止,我的代码中只有这些字符未涵盖。

So far i'm using到目前为止我正在使用

if (char.IsLetterOrDigit(Convert.ToChar(tb.SelectedText)) || (char.IsSymbol(Convert.ToChar(tb.SelectedText))) || (char.IsSeparator(Convert.ToChar(tb.SelectedText))))

试试这个方法:char.IsPunctuation(char c)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM