简体   繁体   中英

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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