try
{
// put the code here that may raise exceptions
}
catch
{
// handle exception here
}
finally
{
// final cleanup code
}
public class CustomException: Exception
{
public CustomException() { }
public CustomException(string message) : base(message) { }
public CustomException(string message, Exception innerexception) : base(message, innerexception) { }
}
Sample
throw new ArgumentOutOfRangeException(nameof(amount), "Amount of deposit must be positive");
throw new InvalidOperationException("Not sufficient funds for this withdrawal");