Actually, not entirely. Upon reading the definintions of
a large number of the clear methods in the framework, I
see threee basic categories:
1. Clear releases the resources for the object
2. Clear resets the object to an initial state
3. Clear removes all elements of the collection, but
does not appear to reset the state. (Clear is a big part
of CollectionBase derived classes, as one would suspect.)
My coworker's concern was that he believed that a call
to "Clear()" on a collection associated with a database,
followed by a save, should essentially remove all the
associated records from the database. Essentially,
Clear() = RemoveAll(). Thus he believes the meaning
of "Clear()" is not consistent among the objects in
the .Net framework.
My impression was that "Clear()" was used to reset the
object to an initial state, so I use "Clear()" in my
configuration application when changing tasks, or prior
to exit, much as the DOS command CLS was used when I was
much younger. If Clear means "reset the object to an
initial state", then IList.Clear() is essentially the
same as Graphics.Clear() or CryptoStream.Clear().
The result of the confusion, as you might expect, is an
application that raises the "I am dirty, do you want to
save?" message, and if the user selects "Yes", all the
records in the database are deleted! Thus we require
some clarification (believe me, I am trying to be careful
not to use the word "Clear" here) as to whether or not
there is a generalized definition and usage for this
method call.
Thank you to all for the clarifications to date.