throw is very handy when you want to generate exception through your code. For example if the class is inheriting interface and one of the method you dont want to implement in that case you can put like throw throw new NotImplementedException(); . Additionally for the precautionary measure if you know the range which your method can handle you can raise the exception if the method reaches to the maximum value.

2 Users have rated as useful.
Login to rate this answer.
throw is used in catch block to throw user define exceptions.
ex: throw ( new Exception(" User is not correct"))
Login to rate this answer.
Suresh Jayaraman
Answered On : Sep 23rd, 2011
if we have different layers like Dataaccess layer,Business layer ,Presentation layer.
The error is in DataAccess layer,that error should come to presentation layer and we can show that error in message box.it is possible when using throw keyword in try catch block
Ex:
In DataAccessLayer
public void InsertCustomerDAL()
try
{
}
catch(Exception ex)
{
throw ex;
}
Business Layer
InsertCustomerDAL obj=new InsertCustomerDAL();
public void InsertCustomerBL()
try
{
call DAL method here
}
catch(Exception ex)
{
throw ex;
}
Presentation layer
try
{
call BL Method here
}
Catch(Exception ex)
{
this.lblMessage=ex.Message;
}
Login to rate this answer.
no throws in C#.
throw is used to re-throw exceptions
Login to rate this answer.