I'm modelling a list of strongly typed database keys. Some will be ints, some strings, some guids etc.
EDIT They are strongly typed in the sense that some of the keys will contain integer values, some strings, some uids etc.
So if my class for the Key was "Key" and my list was List<Key>
I'm looking for how to implement the strongly typed aspect. I don't want to use generics as I don't think its appropriate here (prove me wrong though).
I'm thinking of making "Key" and abstract class and making each subclass implement the strongly typed aspect. But this will be messy as well. (see below)
Does anyone have any better ideas?
public abstract class RowKey
{
public string DbName { get; set; }
public abstract object GetTypedValue();
}
public class IntegerRowKey: RowKey
{
public override object GetTypedValue()
{
return 1;
}
}