For the record, I am testing two codes: That simply try to convert from a string to a number and if it fail then assign number to zero.
if (!Int32.TryParse(txt,out tmpint)) {
tmpint = 0;
}
and:
try {
tmpint = Convert.ToInt32(txt);
} catch (Exception) {
tmpint = 0;
}
For c#, the best option is to use tryparse because try&Catch alternative thrown the exception
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
That it is painful slow and undesirable, however, the code does not stop unless Debug's exception are settled for stop with it.