|
Hello..........
I am beginner in c# programming, want to know How does this code executes. Kindly describe in detail.
!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+")
Soon reply will be appreciated.....!!!!
Thanks....
|
|
|
|
|
Calls the method "IsMatch" on the Regex class (from the "System.Text.RegularExpressions" namespace), with the arguments of the current keycharacter (provided by an event you did not copy/paste) and a RegEx. Then it inverses the outcome.
Not very helpful, is it? It compares a key with a RegEx and reports whether they match. You'd have to look up the "\\d+" part on this page[^] from MSDN, I don't know the regex-code from my head.
|
|
|
|
|
It tests whether the e.KeyChar property (which is presumably a char ) is not (note the ! at the start) a decimal digit.
It's a significantly less efficient version of:
!(e.KeyChar >= '0' && e.KeyChar <= '9')
or:
(e.KeyChar < '0' || e.KeyChar > '9')
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|