I am wondering whether there is way to limit the Type variable to a certain class only. For example
public class Product
{
public string Name;
public bool Install;
public List<Type> Components;
public List<Type> Prerequisite;
}
If the List can be specified to be of typeof(Product) and its derivatives, I think it will make my generic design much more straightforward and easy to use. Maybe like so:
public class Product
{
public string Name;
public bool Install;
public List<Type<Product>> Components;
public List<Type<Product>> Prerequisite;
}
Do you know of a method to do so? Thank you for your thoughts.
Aucun commentaire:
Enregistrer un commentaire