Overloading names and properties in VB.NET

I have a base class with the following enumeration and property:

    Public Enum InitType
        Focus = 0
        Help = 1
        ErrorToolTip = 2
    End Enum

    Property ToolTipInitType() As InitType
        Get
            Return m_initType
        End Get
        Set(ByVal value As InitType)
            m_initType = value
        End Set
    End Property

I would like to create a derived class that extends the enumeration, so the enumeration of derived classes will be:

    Public Enum InitType
        Focus = 0
        Help = 1
        ErrorToolTip = 2
        HelpPopUp = 3
    End Enum

First of all, how do I do this - is it just overloading it? And secondly, will my original property automatically receive a new enumeration when using a derived class, or will I also need to overload it?

Any help is greatly appreciated.

thank

Addict

+3
source share
1 answer

, , . , . , / , .

Public Class InitType
    Protected Sub New()
    End Sub
    Public Shared ReadOnly Focus As New InitType()
    Public Shared ReadOnly Help As New InitType()
    Public Shared ReadOnly ErrorToolTip As New InitType()
End Class

. :

Public Class ExtendingEnums
    Private m_initType As InitType = InitType.Focus
    Property ToolTipInitType() As InitType
        Get
            Return m_initType
        End Get
        Set(ByVal value As InitType)
            m_initType = value
        End Set
    End Property
End Class

, "enum", :

Public Class InitTypeEx
    Inherits InitType
    Public Shared ReadOnly HelpPopUp As New InitType()
End Class

.

Public Sub Execute()
    Dim ee As New ExtendingEnums()
    ee.ToolTipInitType = InitType.Help
    ee.ToolTipInitType = InitTypeEx.HelpPopUp
    ee.ToolTipInitType = InitTypeEx.Focus
End Sub
+4

Source: https://habr.com/ru/post/1766183/


All Articles