C# generic inheritance and covariance part 2

There does not appear to be any question in this question, so I’ll make up a few questions to answer. What is a covariant conversion? Let’s suppose we have some types Fruit and Apple and Banana with the obvious relationships; Apple is a kind of Fruit, and so on. A covariant conversion is one where … Read more

KeyValuePair with generic values [closed]

First of all, List<T> accepts only one generic argument, so you cannot specify both string and KeyValuePair<string, T>. As pointed out, maybe you mean a Dictionary<K, V>? Generally, your code with the T argument is only possible if it appears within a generic method or class that itself accepts a type argument named T. If … Read more

How to capture value OOPS & Generic [closed]

While looking at your code, why would one want to read class specific properties in a generic method? The only solutions i see is to use Reflection, or create an abstract base class with a before save method and call that method in de Save() method. Add a generic type constraint to the DBObject class … Read more

iterating through item of array of generic collections

If you want to declare IObsColDoor variables, and use them in foreach, you need to inherit IObsColDoor from IEnumerable: public interface IObsColDoor : IEnumerable { } Since ObsColDoor<T> is an ObservableCollection<T>, you don’t need to implement IEnumerable in ObsColDoor<T> class, because it is already implemented. Note, that: since IObsColDoor have not any generic functionality, you … Read more