Click here to Skip to main content
15,892,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: giving error message according to Sql data PinPopular
Not Active8-Dec-10 5:20
mentorNot Active8-Dec-10 5:20 
GeneralRe: giving error message according to Sql data Pin
T M Gray8-Dec-10 5:37
T M Gray8-Dec-10 5:37 
GeneralRe: giving error message according to Sql data Pin
Not Active8-Dec-10 5:44
mentorNot Active8-Dec-10 5:44 
GeneralRe: giving error message according to Sql data Pin
T M Gray8-Dec-10 7:54
T M Gray8-Dec-10 7:54 
GeneralRe: giving error message according to Sql data Pin
Not Active8-Dec-10 8:28
mentorNot Active8-Dec-10 8:28 
GeneralRe: giving error message according to Sql data Pin
T M Gray8-Dec-10 9:00
T M Gray8-Dec-10 9:00 
GeneralRe: giving error message according to Sql data Pin
Dave Kreskowiak8-Dec-10 10:56
mveDave Kreskowiak8-Dec-10 10:56 
GeneralRe: giving error message according to Sql data Pin
AspDotNetDev8-Dec-10 11:58
protectorAspDotNetDev8-Dec-10 11:58 
Dave Kreskowiak wrote:
If a known condition can be tested for without relying on an exception, it's a best course of action.


Well, I wouldn't say that's always true. Imagine if TryParse didn't exist. Would you rather Try/Catch a Parse or re-implement a version of parse that returns a bool if the string is invalid? Given the complexity of number formats (e.g., scientific notation), I would just do a Try/Catch. I guess this can be generalized as:

If a known condition is exceptionally complex to test for, then just use exception handling to test if it's valid.

Here's another example. I built a tool that allows the user to enter a regular expression to match against some data. Rather than validate that the regular expression is valid, I just used Try/Catch to catch exceptions thrown by invalid exceptions. I mean I COULD first check if the regular expression is valid, but it would be exceedingly complex and a waste of time when the test for validity already exists in the form of exception handling.

GeneralRe: giving error message according to Sql data Pin
Dave Kreskowiak9-Dec-10 2:01
mveDave Kreskowiak9-Dec-10 2:01 
GeneralRe: giving error message according to Sql data Pin
Eddy Vluggen8-Dec-10 9:32
professionalEddy Vluggen8-Dec-10 9:32 
GeneralRe: giving error message according to Sql data Pin
PIEBALDconsult8-Dec-10 14:28
mvePIEBALDconsult8-Dec-10 14:28 
GeneralRe: giving error message according to Sql data Pin
Not Active8-Dec-10 15:22
mentorNot Active8-Dec-10 15:22 
GeneralRe: giving error message according to Sql data Pin
PIEBALDconsult8-Dec-10 15:39
mvePIEBALDconsult8-Dec-10 15:39 
GeneralRe: giving error message according to Sql data Pin
Not Active8-Dec-10 16:12
mentorNot Active8-Dec-10 16:12 
GeneralRe: giving error message according to Sql data Pin
Gary Wheeler8-Dec-10 9:38
Gary Wheeler8-Dec-10 9:38 
GeneralRe: giving error message according to Sql data Pin
Keith Barrow8-Dec-10 10:43
professionalKeith Barrow8-Dec-10 10:43 
GeneralRe: giving error message according to Sql data Pin
Gary Wheeler8-Dec-10 10:45
Gary Wheeler8-Dec-10 10:45 
GeneralRe: giving error message according to Sql data Pin
Keith Barrow8-Dec-10 10:59
professionalKeith Barrow8-Dec-10 10:59 
GeneralRe: giving error message according to Sql data Pin
PIEBALDconsult8-Dec-10 15:56
mvePIEBALDconsult8-Dec-10 15:56 
GeneralRe: giving error message according to Sql data Pin
Not Active8-Dec-10 16:18
mentorNot Active8-Dec-10 16:18 
GeneralRe: giving error message according to Sql data PinPopular
Nish Nishant8-Dec-10 9:19
sitebuilderNish Nishant8-Dec-10 9:19 
GeneralRe: giving error message according to Sql data Pin
Not Active8-Dec-10 9:26
mentorNot Active8-Dec-10 9:26 
GeneralRe: giving error message according to Sql data PinPopular
Nish Nishant8-Dec-10 9:35
sitebuilderNish Nishant8-Dec-10 9:35 
GeneralRe: giving error message according to Sql data Pin
Not Active8-Dec-10 9:37
mentorNot Active8-Dec-10 9:37 
GeneralRe: giving error message according to Sql data Pin
Nish Nishant8-Dec-10 9:41
sitebuilderNish Nishant8-Dec-10 9:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.