Assert, at least in .NET, is used for testing in the first place. Its specific use is presented briefly here :
An assertion is best used to verify a condition only if the following conditions are true:
* the condition should never be false if the code is correct,
* the condition is not so trivial so as to obviously be always true, and
* the condition is in some sense internal to a body of software.
In production code, I would recommend the first method; or try/catchif "something bad" is never expected; if this is an exceptional condition.
, ( ), Assert .
; . .