Try putting "return true" after the catch block. It would like this after making that change:
private bool isValid(string idOne, string idTwo) { try { int id1=int32.parse(idOne); int id2=int32.parse(idTwo); } catch ( exceptionname error) { messageBox.show( "Error: " + error);
return false; }
return true; }
You might get some folks telling you not to verify the validity of input like this, but I wouldn't worry about it too much. If you had a method that could be called potentially thousands of times, then yeah you should look into something like RegEx or
int.TryParse(if .NET 2.0) for your validation. The reason being is that exceptions are fairly expensive performance-wise.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C-Sharp (C#)" group. To post to this group, send email to C_Sharp googlegroups.com To unsubscribe from this group, send email to C_Sharp-unsubscribe googlegroups.com For more options, visit this group at http://groups-beta.google.com/group/C_Sharp?hl=en -~----------~----~----~----~------~----~------~--~---
|