草庐IT

IsDescendantOf

全部标签

c# - 检查 System.Type 是否是给定类的后代的最佳方法

考虑以下代码:publicclassA{}publicclassB:A{}publicclassC:B{}classD{publicstaticboolIsDescendantOf(thisSystem.TypethisType,System.TypethatType){///???}voidMain(){AcValue=newC();C.GetType().IsDescendantOf(cValue.GetType());}}实现IsDescendantOf的最佳方法是什么? 最佳答案 Type.IsSubclassOf()判断当