mercredi 14 janvier 2015

Casting System.Type to a specific class

I'm getting the desired System.Type using reflection. I need to check if it is a descendant of Component class. If it is I need to add this particular class to List. What is the proper way to convert types?



foreach (Type curType in allTypes)
{
if (curType descends from Component)
componentsList.Add( (Component)curType );
}





Aucun commentaire:

Enregistrer un commentaire