> I have a small program which has 2 variables(1 string > variable and other an integer variable). I have to > convert the value in the string variable to an integer > and store it in the integer variable. Before > converting it into an integer I want to check whether > the string varibale contains valid numbers if so, I > would go ahead and convert otherwise I have to store > 0.
This should do the trick: try { val = Int32.Parse(str1) } catch(FormatException) { val = 0; } catch(ArgumentNullException) { val = 0; } -- Steve Johnson 3t Systems You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.