How do I know if a type inherited some other type?

how do you know if a type inherited some other type?

Type t;
// i get the t from somewhere
bool b = t.IsInhertitedFrom(typeof(BaseType));
+3
source share
1 answer

bool b = t.IsSubclassOf (typeof (BaseType))

and check if the interface type uses the interface:

bool b = t.GetInterface (typeof (IMyInterface) .FullName)! = null

+12
source

Source: https://habr.com/ru/post/1723879/


All Articles