Found this question rather late but I wanted to chime in.
Interfaces in C# have an is-a relationship, but not is-an-object. Rather, is-an-implementation.
In other words, for class Foo that implements IBar, the following test:
Foo myFoo = new Foo();
return myFoo is IBar;
literally returns true. You can also say,
IBar bar = myArrayList[3] as IBar;
Foo foo = bar as Foo;
Or, if a method requires an IBar, you can pass a Foo.
void DoSomething(IBar bar) {
}
static void Main() {
Foo myFoo = new Foo();
DoSomething(myFoo);
}
Obviously, an IBar has no implementation in itself, so the can-do relationship also applies.
interface IBar { void happy(); }
class Foo : IBar
{
void happy()
{
Console.Write("OH MAN I AM SO HAPPY!");
}
}
class Program
{
static void Main()
{
IBar myBar = new Foo();
myBar.happy();
}
}
But, for that matter, the same is true of object inheritance; an object of class Foo that inherits class Bar has a can-do relationship as well as an is-a relationship, in the same way as the interface does. It's just that its implementation was pre-built for it.
The real question is, is-a-what, can-do-what? An inherited class object is-a-[parent instance] and can-do-[parent's behavior], whereas an implementation of an interface is-an-[interface implementation] and therefore can-do-[the interface behavior].
In most cases where programmatic is-a relationships are used such as those listed above, only the interface is evaluated, so both an inherited class and an implemented interface share the same is-a and can-do qualities.
HTH,
Jon