在编程中查找指定类型的派生类型
var listofderivedTypes =(( 从appdomain.currentdomain.getAssemblies()中的domainAssembly。 从type in domainAssembly.getTypes() 其中typeof(basetypename)。 select type).ToArray();
Alternative Fluent Syntax:The LINQ expression can also be written in a more fluent style for enhanced readability:
var listOfDerivedTypes = ( from domainAssembly in AppDomain.CurrentDomain.GetAssemblies() from type in domainAssembly.GetTypes() where typeof(BaseTypeName).IsAssignableFrom(type) select type).ToArray();排除原始基类:
,将原始基本类型包含在结果中,add && type!= type!= type!= type!= type!= type!= type!= where clause。 type.isabstract至Whewer子句。通用类型:处理通用类型需要其他注意事项。有关指导,请参阅“详细信息”部分中的链接资源。
免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。
Copyright© 2022 湘ICP备2022001581号-3