tags:

views:

185

answers:

3

I have seen this statement in many of the documention samples, like here

This class is the default implementation of the "ISomeInterface" interface

what exactly this means ? Thanks

+2  A: 

It means that when you call the Sort method without argument (without explicitly specifying a comparer) it will use this default implementation.

Darin Dimitrov
A: 

This means this class is the one implementing the interface. It points to the object that implements the interface itself without any derived or inherited members, but plainly the interface. This is the class that cirectly corresponds to this interface.

public interface IComparer {
    // Some members to implement here.
}

public class Comparer : IComparer {
    // IComparer members implementation
}
Will Marcouiller
+6  A: 

This is somewhat misleading, since an interface, by definition, provides no implementation.

However, many portions of the framework try to make life easier - so they provide a method which takes an interface, but also provides an overload with no parameters. A good example is List<T>.Sort.

The documentation here is suggesting that, if you use a method that would normally require an IComparer<T>, but use it via some overload that doesn't, you'll get the referenced "default implementation" used instead.

However, this is really an "implementation detail" of classes unrelated to the interface itself. I personally think this is a poor choice of words in the documentation, and should be something more like:

Many types in the framework rely on a common implementation of this interface provided by the Comparer class.

This would, in my opinion, provide a more clear meaning to this...

Reed Copsey
I really like such explanations! =)
Will Marcouiller
@Will: Thanks! I do my best ;)
Reed Copsey
Add something. Sometimes, a framework uses Special Cases pattern (or Null Object pattern), and a default implementation of an interface can be part of the pattern. :)
Lex Li