RangeArray
throws an object of type
RangeArrayException
.
Notice there are three places in
RangeArray
that this might occur: in the
get
indexer accessor,
in the
set
indexer accessor, and by the
RangeArray
constructor. To catch these exceptions
implies that
RangeArray
objects must be constructed and accessed from within a
try
block,
as the program illustrates. By using an exception to report errors,
RangeArray
now acts like
one of C#’s built-in types and can be fully integrated into a program’s exception-handling
mechanism.
Notice that none of the
RangeArrayException
constructors provide any statements
in their body. Instead, they simply pass their arguments along to
Do'stlaringiz bilan baham: |