怎么知道Type是否继承了其他类型?
Type t;
// i get the t from somewhere
bool b = t.IsInhertitedFrom(typeof(BaseType));
Run Code Online (Sandbox Code Playgroud)
Jar*_*das 12
bool b = t.IsSubclassOf(typeof(BaseType))
并检查类型是否实现接口使用:
bool b = t.GetInterface(typeof(IMyInterface).FullName)!= null
| 归档时间: |
|
| 查看次数: |
189 次 |
| 最近记录: |