Inheritance of Custom Attributes on Abstract Properties

前端 未结 5 1528
萌比男神i
萌比男神i 2020-12-01 20:42

I\'ve got a custom attribute that I want to apply to my base abstract class so that I can skip elements that don\'t need to be viewed by the user when displaying the item in

5条回答
  •  既然无缘
    2020-12-01 21:02

    Looks like it only happens when the overriding method also has the attribute .

    http://msdn.microsoft.com/en-us/library/a19191fh.aspx

    However, you can override attributes of the same type or apply additional attributes to the derived component. The following code fragment shows a custom control that overrides the Text property inherited from Control by overriding the BrowsableAttribute attribute applied in the base class. Visual Basic

    Public Class MyControl
       Inherits Control
       ' The base class has [Browsable(true)] applied to the Text property.
         _
       Public Overrides Property [Text]() As String
          ...
       End Property 
       ...
    End Class
    

提交回复
热议问题