.NET Hawa

Design Patterns – I (Introduction)

Authoring software requires a set of rules and methodologies to take your idea to center point without any rework for future enhancements.  In Software Engineering, we have a set of principles stated by Robert Martin called SOLID principle.   SOLID word has principles as Single Responsibility, Open Close, Liskov’s Substitution, Interface Segregation and Dependency Inversion. Let me explain you about SOLID as one word

SOLID Read the rest of this entry »

Advertisements
2 Comments »

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 »

Performace Grading in Integer Conversions

  As we are working with .Net, libraries will also have similar meathods for perform single operation we need to know what is the better one and what is a big one. I searched over internet and here i am explaining giving information about some known meathods, Integer.Parse(), Convert.ToInt32(),Integer.TryParse().

Integer.Parse():

Integer.Parse() method should have argument as String datatype. It will parse the string for integer value. If it has no integer value or it contains mixture of integer and characters it will throw you a exception.

Syntax:

Integer.Parse(string S)

Integer.TryParse():

Integer.TryParse takes arugments as string and an Integer. This fucntion will return boolean value. This function will work same as Integer.Parse() but it will not throw any exception. If string does not contains any integer value it will return false.

Syntax:
Integer.TryParse(String S, Out Integer I)

Convert.ToInt32():

This will work as same as Integer.Parse(). So I am not explaining more about this. Convert.Toint32() aceepts null as a argumnet. Integer.Parse() will accept. Convert.ToInt32() internally calls Integer.Parse()

The main difference is taking out with the performance

Integer.TryParse() > Convert.Toint32() > Integer.Parse()


Because Integer.Parse() will throws exception when it has string or null value. Convert.toInt32() check for null string if it is null it will directly throw exception and if it is not null it will call integer.parse() meathod. Integer.TryParse() will try to parse all values and returns boolean values.

Leave a comment »