But what happens when a conversion is necessary? Can that throw an exception? If your
assignment invokes an implicit conversion, you??™re covered, assuming that any custom implicit
conversion operators don??™t throw. You must take great care not to throw an exception in your
custom implicit conversion operators. However, explicit conversions, in the form of casts, can
throw. The bottom line is, a simple assignment from one reference to another, whether it
requires implicit conversion or not, will not throw.
Simple assignment from one reference location to another is all that ListSwap() is doing.
After you set up the temporary ArrayList objects with the desired state, and you??™ve gotten to
the point of even executing the ListSwap() calls, you??™ve arrived at a point where you know that
no more exceptions in the TerminateEmployee() method are possible. Now, you can make the
switch safely. The ArrayList objects in the EmployeeDatabase object are swapped with the temporary
ones. Once the method completes, the original ArrayList objects are free to be collected
by the garbage collector (GC).
One more thing that you may have noticed regarding ListSwap() is that the temporary
location to store an ArrayList instance during the swap is allocated outside of the ListSwap()
method and passed in as a ByRef parameter.
Pages:
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252