c# - I wanted to understand the purpose of this code snippet -
can please explain purpose of c# code. it's code snippet in windows based application. counting number of keypress? purpose of 13 here?
any appreciated
private void num2_keypress(object sender, keypresseventargs e) { if ((int) e.keychar != 13) return; this.calculate(); }
that code unfortunately written - keypresseventargs.keychar
returns character pressed (so shift-a return 'a' example). 13 unicode character "carriage return" returned when user hits return. have written method as:
// possibly rename calculateifreturnispressed or similar. private void num2_keypress(object sender, keypresseventargs e) { // perform calculation if user hit return if (e.keychar == '\r') { calculate(); } }
\r
same character (char) 13
.
Comments
Post a Comment