I\'ve been using c# since version 1, and have never seen a worthwhile use of member hiding. Do you know of any?
When a new version of a Type implements a publicly-visible member whose name conflicts with a name you've used in a derived Type.
To hide an inappropriate implementation in a base class from which you derive.
For example KeyedCollection
is inherited from Collection
and is therefore an O(n) operation rather than the O(1) operation that KeyedCollection
usually provides.
This is arguably confusing as naive consumers may think the two are interchangeable.
So it may be appropriate to implement a "better" version:
public new bool Contains(TItem item)
{
if (item == null) throw new ArgumentNullException("item");
return this.Contains(GetKeyForItem(item));
}