I'm trying to define a generic class that accept as argument a value type (actually it will be an enum) and initialize a const field with it's default type.
I want something like:
public abstract class GenericClass<ValueType>
where ValueType: struct, IConvertible
{
public const ValueType val = default(ValueType);
}
Unfortunately the compiler complaints (I'm using Mono but I think it's the same on .NET). The error is the following:
error CS1959: Type parameter `ValueType' cannot be declared const
What's my error?