Sunday, January 01, 2006


For parsing base type the .NET Framework 2.0 introduces a pattern across all the relevant base types called TryParse, which mimics Parse. The difference in behavior is that Parse will throw an exception when the data check fails, while TryParse simply goes to an else statement


Dim iVal As Integer
If Int32.TryParse(someString, iVal) Then
' code which deals with the valid integer
' code which deals with an invalid input
End If