Skip to content

给属性添加说明

有时,属性的功能或用法并不能通过属性名直接被理解,此时应该给属性添加一些描述,详细说明属性的功能,用法或特殊策略

通过标注 DescriptionAttribute 可以实现此功能

示例代码

csharp
    public class MyPluginCellType : CellType
    {
        [Description("这里可以写一些描述")]
        public string MyProperty1 { get; set; }
        [Description("描述文本可以是多行的\r\n通过鼠标悬停到问号图标上查看")]
        public bool MyProperty2 { get; set; }
    }

设计器中的效果
1669996577136-0beb9497-f0aa-4848-ac38-4d341370a5eb.png

更新: 2022-12-02 23:56:36
原文: https://www.yuque.com/robert-bh51n/ea8l6c/uhe6pw5qwgcu6bin