Different type of generic classes in a list

I recently came across a functionality where I need to have a generic class with a generic property. As an example I needed different field classes where each field has it’s value. I have two different classes for a string and an integer. public interface IField<TValue> { TValue Value { get; set; } } public class StringField : IField<string> { public StringField() { this.Value = "my string"; } public string Value { get; set; } } public class IntField : IField<int> { public IntField() { this.Value = 7; } public int Value { get; set; } } Now…

Keep reading