Nathan J Pledger

Program.X musings from the Isle of Man concerning ASP.NET, in particular accessibility, web standards and neat ideas.

August 2006 - Posts

Wouldn't you like to see: Inherited Enumerations?

Came across this idea today and I do say it owuld be rather useful.

I have a series of classes that provide different types of offer for products, based on a shopping basket.

I have an enumeration that identifies the result of an offer being applied:

public enum MediaCodeOfferResult { OfferApplied,
OrderDoesNotQualify,
UnknownError,
MediaCodeOfferError,
MediaCodeOfferTypeError,
AssemblyNotLoaded,
TypeNotLoaded,
TypeNotCastable }

But I would like to use the same enumeration to identify, with more granularity, what went wrong in each of the classes. eg.:

public enum MediaCodeOfferXForYResult { InsufficientInput } : MediaCodeOfferResult;

Wouldn't this be useful?

I can't see that it would be that difficult to do. An enum is just an int, after all. I find them really useful for quick and dirty result codes, like this, that don't need frameworks to be built to return values that can be accounted for and reacted against.