0

So the checked block don't allow overflow in arithmetics operations, but i don't see why use the checked block instead of the try block, cause try don't allow either overflow exception.

So my question is, why use the checked box instead of the try block? What is my leverage using the checked box?

Edit: I'm not asking what is checked block, i'm asking my leverage in using it instead of an try catch

Patrick Sampaio
  • 390
  • 2
  • 13
  • 4
    If you don't wrap your operations on a `checked` scope, then the operations will overflow, *without throwing any runtime exception*. So, using `try/catch` without a `checked` does not make sense at all – Matias Cicero Jun 01 '17 at 02:45
  • 1
    `checked` controls _whether_ an exception is thrown; `try`/`catch` controls how your code _handles_ an exception. They are two completely different features. – Peter Duniho Jun 01 '17 at 02:54
  • @MatiasCicero Are you sure that inside an try catch an overflow exception will not be throwed? – Patrick Sampaio Jun 01 '17 at 03:06

0 Answers0