Click here to Skip to main content
15,921,295 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
try
{
   if (Validate())
     {
        if (MakePerson())
           RadMessageBox.Show("ok");
        else
          throw new Exception(ex1);
     }
   else
        throw new Exception(ex2); 
 }
catch 
{
   if(ex1) 
      RadMessageBox.Show("custommessage1")
   if(ex2)
      RadMessageBox.Show("custommessage2")
}
Posted

1 solution

C#
try
{
 // statements that can cause exception.
}
catch (MoreSpecificExceptionType e1)
{
 // error handling code
}
catch (SpecificExceptionType e2)
{
 // error handling code
}
catch (GeneralExceptionType eN)
{
 // error handling code
}

[ for more reference, go here[^] ]

And this will help you out as well,
stackoverflow[^]
MSDN[^]
c#-corner[^]
hblog.gurock.com/[^]

-KR
 
Share this answer
 
v2
Comments
mit62 16-Feb-14 21:50pm    
would you please tell me how write throws?
Krunal Rohit 16-Feb-14 21:51pm    
catch(ZeroDivideException ex)
{
throw new Exception(ex.Message);
}

Is it ?
-KR
mit62 16-Feb-14 21:53pm    
and how I call Catch when code in Try is wrong?
Krunal Rohit 16-Feb-14 21:55pm    
Whenever the Try block is not executed (some exception must be there), then Catch block automatically executed. So control automatically goes to the Catch block, and there you are.

-KR
Krunal Rohit 16-Feb-14 21:56pm    
Refer the link from the Solution.

-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900