c# 4.0 - How to create a List which contains a type of interface, to only add class types which inerhit this interface? -
i want create collection of class types, want types, not objects - inerhit
ibuildertype so how write list ->
public list<typeof(ibuildertype)> builder; to achieve :
var listbuilder = new list<typeof(ibuildertype)> {typeof (basiccategorybuilder)}; i want basicly restriction types can add list (range of classes)
type isn't generic, cannot check @ compile time elements of list`1 types of ibuildertype. may want check type hierarchy code , encapsule list methods, there's no way constraint type in generics.
var listbuilder = new list<type/* : ibuildertype*/>() { typeof(basiccategorybuilder) };
Comments
Post a Comment