[Mono-list] Parametized generics puzzler
ebichete
ebichete at yahoo.com
Wed Jan 28 07:40:42 EST 2009
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.
- Edward -
using System.Collections.Generic;
public class Vehicle {
protected const string REG_TYPE = "";
protected static string TAX_CAT = "";
public static string getRegType() where T : Vehicle
{
return T.REG_TYPE;
}
public static string getTaxCategory() where T : Vehicle
{
return T.TAX_CAT;
}
}
public class Truck : Vehicle {
protected new const string REG_TYPE = "G";
protected new static string TAX_CAT = "J4";
}
public class GenericsBug {
public static void Main(string[] args)
{
System.Console.WriteLine("Registration Class: " + Truck.getRegType());
System.Console.WriteLine("Tax Category: " + Truck.getTaxCategory());
}
}
--
View this message in context: http://www.nabble.com/Parametized-generics-puzzler-tp21704985p21704985.html
Sent from the Mono - General mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20090128/e2bb2146/attachment-0001.html
More information about the Mono-list
mailing list