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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -