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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -