Sunday, July 02, 2006

.NET in Human Relations - Part - 1

Let me explain you what is Try- Catch Block.
Consider a typical function in .NET

Public Function CalculateSum(Byval num1 as String, Byval num2 as String) as Integer
Try
Dim number1 as Integer = CType(num1,Integer)
Dim number2 as Integer = CType(num2,Integer)
Return number1+number2
Catch formatex as Formatexception
MessageBox.Show("The Parameters provided is not a number")
Catch ex as Exception
MessageBox.Show("Cannot perform the operation. Try with another set of values")
End Try
End Function


Ok. This is a simple function where two parameters are provided as string into the function CalculateSum. This function converts this string into Integer and returns the Sum of them in Integer(Number) Format.


If we(Environment) are going to provide correct values the function is going to execute well. suppose parameter1 is given as "Divya" - Will it be possible to convert it to number. No!!


So the application will throw exception indication i dont know how to act with this kind of data please help... Exception is understood as something which is not under normal conditions. A good program must anticipate such exception and act according. Here i am catching the exception and handling it will appropriate message.


In exceptions only we can realize the significance of Try - Catch block. Try Catch block is always keen is catching any exception and handles according to the code written within it. Catch block can be specific. In the sense it can handle exceptions according to the type of exception. For example FormatException happens in the case when i try to convert a alphabetic string to integer. Here it can handle by saying "The Parameters provided is not a number".


Hence i can see that you understand the power of Catch Block. Let us not get into detail for this. Since this article is not intended to be too technical. ;-)


How this is related to human relations??
Here is goes .....


Mothers are always like a Try-Catch Block.. Whenever exceptions happen to our life they know how to handle. Our execution of life cannot be safe without Mothers because we never know what exceptions our Environment will throw on us.


I know i need not explain this anymore. I hope you set the context right.


Please pour in your comments,
Cheers,
Divya.S

1 comment:

Anonymous said...

magnus http://jguru.com/guru/viewbio.jsp?EID=1534438 detonated http://jguru.com/guru/viewbio.jsp?EID=1534439 freestone http://jguru.com/guru/viewbio.jsp?EID=1534440 nergizoglu http://jguru.com/guru/viewbio.jsp?EID=1534441 paradigms http://jguru.com/guru/viewbio.jsp?EID=1534443 charito http://jguru.com/guru/viewbio.jsp?EID=1534445 chaplaincy http://jguru.com/guru/viewbio.jsp?EID=1534449 expedition http://jguru.com/guru/viewbio.jsp?EID=1534451 induction http://jguru.com/guru/viewbio.jsp?EID=1534452 ararimu http://jguru.com/guru/viewbio.jsp?EID=1534453 nakada http://jguru.com/guru/viewbio.jsp?EID=1534455 homecoming http://www.kindel.com/members/Furnace-Filters.aspx auwww