public abstract Column<T> { private T Value {get;set;} public abstract string Format(); } public class DateColumn : Column<DateTime> { public override string Format() { return Value.ToString("dd-MMM-yyyy"); } } public class NumberColumn : Column<decimal> { public override string Format() { return Value.ToString(); } }
The problem is to add them to the general collection. I know this is possible, but how can I store several types in a collection, etc.
IList<Column<?>> columns = new List<Column<?>()
I would really appreciate any advice on achieving this. The goal is to have different types of columns stored in the same list. It is worth mentioning that I use NHibernate and the discriminator to load the corresponding object. Ultimately, the value must be of the class type.
Thanks so much for your help in advance.
Jonathan
source share