Link to home
Start Free TrialLog in
Avatar of ksd123
ksd123

asked on

Need advice on try catch blocks in c#

Hi Experts,

I have web application with 8 buttons  and each button has different functionality and am  using try {} catch {} blocks in each button click event.

1)Can I use  try,catch blocks  this many times in a page ? Is this best practice?

2)Is there any differnce between below 2 statements?

a)Class1 obj;
obj=new Class1();

b)Class2 obj=new Class2();

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1. you can use Try Catch as per your requirement. if possible write exception in some file or database. so you can trace it easily.
 
try this tool for Error logging ; https://code.google.com/p/elmah/

2. No difference.
Avatar of ksd123
ksd123

ASKER

Thank you all.