c# - 如何在不提及派生类名称的情况下返回接口(interface)类型?

标签 c# inheritance interface types

我正在寻找一种方法来引用类名,但仍能达到预期的效果。 我不能执行 ITypedList.GetType(),因为它是一个接口(interface)。

public class DerivedList : ITypedList  
...  
public PropertyDescriptorCollection GetItemProperties()  
{  
    return TypeDescriptor.GetProperties(typeof(DerivedList));  
}  
...  

我想知道这是否可能。

干杯,
编辑:尝试用没有提及它自己的类名的东西替换它

最佳答案

绝对...

    public PropertyDescriptorCollection GetItemProperties()
    {
        return TypeDescriptor.GetProperties(this);  
    }

关于c# - 如何在不提及派生类名称的情况下返回接口(interface)类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/896061/

相关文章:

c# - WCF 客户端 - 最佳实践

c# - Visual Studio 2015 非常慢

css - 如何使 css 导航菜单 "selected"选项仍然可点击

inheritance - Backbone : Inherited Models not working in Collection with ID

objective-c - 将实例变量放在没有 getter 和 setter 的 .h 中有什么用(即没有人可以设置或获取它)?

c# - WCF URL 主机段更改为完整域名

c# - 如何使用 Npoco FetchOneToMany?

java - 如何从继承类调用的抽象类调用抽象方法

java - 关于java中ADT树的问题

java - 接口(interface)内的嵌套类是隐式静态和最终的吗?