Saturday, May 14, 2005

Water Bird, Madison, AL

Last Saturday morning Madelyn spotted a largish bird walking along the shore of the retaining pond at Dublin Park, after Caralyn's soccer game there.
The "pond" is probably half an acre, maybe less. But this bird was walking along the shore on its orange legs with a dark blue back and clearly hunting in the water. You couldn't tell it had a pretty long neck since it was cocked back, but then it stuck it out and grabbed a small fish and swallowed it. A minute later it grabbed another. We looked it up, identifying it as a Green Heron.

You can see how they hide their neck here:
This one has his neck extended:

Friday, May 06, 2005

Doubly Inherited Interfaces in C#

Yesterday the question of doubly inherited interfaces in .Net occurred to me when I moved the IDisposable interface to be a base interface for IMyInterface. This is the classic "diamond inheritance" issue from languages that allow true multiple inheritance (e.g. C++). (I was adding IDisposable in order to use an IMyInterface instance in a C# "using" statement). A brief search didn't turn up an answer in Visual Studio Help nor on the Internet at large (See Footnote 1). A quick example this morning indicates that C# collapses multiply inherited interfaces into a single implementation, at least that's what the Intellisense (Visual Studio .Net 2003) did as I added IOne and ITwo as base interfaces to "public SomeClass" in a test sandbox solution.

public interface IParent
void ParentMethod();

public interface IOne : IParent
void OneMethod();

public interface ITwo : IParent
void TwoMethod();

public class SomeClass : IOne, ITwo

Attempting to declare ParentMethod explicitly as a member of IOne fails to compile as not a member of IOne, e.g.
"void IOne.ParentMethod()" within SomeClass will not compile whereas void IOne.OneMethod is fine.
This behaves as expected when instantiating a SomeClass object and using it via the interfaces

SomeClass oSomeClass = new SomeClass();

IOne iOne = (IOne) oSomeClass;
ITwo iTwo = (ITwo) oSomeClass;
IParent iParent = (IParent) oSomeClass;




FootNote 1: I did subsequently find some related information in the C# language specification
(, including
my favorite section to date in 13.1.2: "The base interfaces of an interface are the explicit base interfaces and
their base interfaces. In other words, the set of base interfaces is the complete transitive closure of the
explicit base interfaces, their explicit base interfaces, and so on." Hmmm, is my case a complete or a partial
transitive closure? Being more of a practitioner and less of an academecian these days, I read on... Section 13.2.5 is more germaine, dealing with more complex cases than what I had. It implicitly clarified my argualbly more common case. Isn't dot Net fun?