Hello Ignacio Machin ( .NET/ C# MVP )" machin TA laceupsolutions.com,
Yep, exactly.
C# Spec. 15.4
Attempting to remove a delegate from an empty list (or to remove a
non-existent delegate from a non-empty list) is not an error
Thanks very much to you and the others. It's strange however that the
section number you referred to (15.4) is actually 15.3 in the online version
of MSDN I'm now looking at. These section numbers don't correspond at all
however to the official downloaded spec from Sept/2006 but I think there may
be two versions floating around (for the ECMA and ISO perhaps). It's in
section 22.3 of the latter document anyway (on page 367 or 383 if you're
looking at the Adobe page number). The quote there however is:
"Attempting to subtract a delegate from null (or to subtract a non-existent
delegate from a non-empty list) is not an error".
In any case, I was really asking because sometimes you may want to assign
and remove an event in the course of processing a given function. If you
remove it in a "finally" clause however, and you jump through that clause
because of an exception, it's possible that you'll be removing the event
even though it was never assigned (because the exception occurred before
that took place). While you could organize things so this doesn't happen,
it's just not convenient sometimes, in particular when you're cleaning up
different resources (including other events possibly - the code can start to
become unwieldy if you introduce multiple "finally" and/or "catch" blocks if
you can get away with just one). Anyway, thanks again.