.NET Hawa

Visual Studio 2010 Tips and Tricks

Visual Studio 2010 Tips & Tricks. Daily coding improvements best Visual Studio shortcuts.

via Visual Studio 2010 Tips and Tricks.

Leave a comment »

Performance analsys of Char Method

While we are handling keypress event on text box we majorly we use Char type methods for handling
key press events. Here I am explaining the performance difference between char type methods. Here I
am handling key press event for a textbox which I need validate on key press only allows alphanumeric
characters to say.
For first time I am handling following condition on textbox_keypress event
If Char.IsLetter(e.KeyChar) OrElse Char.IsDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
This will handle to enter only alphanumeric characters but not special Characters. Performance of this
procedure ranges like this

test

I gave input as one Integer, One Character and One Special Character any how Special Character will not
allow in the textbox.
On next I am writing same code as:
If Char.IsLetterOrDigit(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If
Following is the performance graph for above code


Explanation of graph is given below:


….To be Continued….

Leave a comment »