On Wed, Jan 28, 2009 at 7:40 AM, ebichete <[email protected]> wrote:
> Does anyone know why the following code doesn't "do the expected thing" ? I
> think I've properly coded my intent in C# but I could be wrong.
>
> I'm trying to get the base class static methods to act differently based on
> static data in the derived classes.
>
> [snip]

The problem here is that you are declaring new members with the same
name on the derived type Truck and are not actually overriding them.
This distinction is important.  Further, static members cannot be
overridden -- period.  What you want is something like:

public class Vehicle {
    public virtual string REG_TYPE { get { return ""; } }
    public virtual string TAX_CAT { get { return ""; } }
}

public class Truck : Vehicle {
    public override string REG_TYPE { get { return "G"; } }
    public override string TAX_CAT { get { return "J4"; } }
}

No generics or obnoxious getter methods needed.

P.S. Names like REG_TYPE are in bad taste.  Try something like RegistrationType.

-- 
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to