C# Catch Exception -



C# Catch Exception -

which exception utilize in try/catch find out when user has inputted info in wrong format?

example:

try { string s = textbox1.text; // user inputs int // input error messagebox.show(s); } catch(what exception) { messagebox.show("input in wrong format"); }

thanks

don't this. it's misuse of exception handling. attempting considered coding exception, anti-pattern.

an exception sounds like, an exception norm. it's defined either haven't accounted for, or can't business relationship through traditional validation. in situation, can business relationship format issue ahead of time. if know there possiblity inputted info in wrong format, check case first. e.g.

if(!validatetext(textbox1.text)) // false validation method, you'd create. { // input wrong. } else { // process. }

c# try-catch

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -