.NET Hawa

Performance analsys of Char Method

on January 8, 2012

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….

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: