开发者

how know if a Type has inherited some other type?

开发者 https://www.devze.com 2022-12-13 00:10 出处:网络
how k开发者_高级运维now if a Type has inherited some other type ? Type t; // i get the t from somewhere

how k开发者_高级运维now if a Type has inherited some other type ?

Type t;
// i get the t from somewhere
bool b = t.IsInhertitedFrom(typeof(BaseType));


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

and to check if type implements interface use:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消