gpt4 book ai didi

.net - PropertyDescriptor 有什么区别。属性类型和组件类型?

转载 作者:行者123 更新时间:2023-12-01 09:32:36 25 4
gpt4 key购买 nike

.NET 上的 PropertyType 和 ComponentType 有什么区别 PropertyDescriptor ?

文档并没有真正解释

PropertyType When overridden in a derived class, gets the type of the property.

ComponentType When overridden in a derived class, gets the type of the component this property is bound to.

最佳答案

就常规属性而言:

class Foo
{
public int Bar { get; set; }
}

如果我们现在通过TypeDescriptor查看Foo.Bar,组件类型是Foo;属性类型是 Int32。基本上,ComponentType 是属性的 DeclaringType(在反射方面)。因此,如果您正在编写自定义 PropertyDescriptor 实现,则 PropertyTypedata 的类型,而 ComponentType目标实例的预期类型

关于.net - PropertyDescriptor 有什么区别。属性类型和组件类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13566578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com