How to list static properties (Shared Property) equal to System.Drawing.Color

Asked

Viewed 40 times

0

I have a structure called Servicos and in it I have some static properties.

Public Structure Servico

        Public Shared ReadOnly Property Instalacao As Servico
            Get
                Return New Servico(ServicesType.Instalacao)
            End Get
        End Property

        Public Shared ReadOnly Property Desativacao As Servico
            Get
                Return New Servico(ServicesType.Desativacao)
            End Get
        End Property

        Public Shared ReadOnly Property TrocaVeiculo As Servico
            Get
                Return New Servico(ServicesType.TrocaVeiculo)
            End Get
        End Property

        Public Shared ReadOnly Property TrocaTitularidade As Servico
            Get
                Return New Servico(ServicesType.TrocaTitularidade)
            End Get
        End Property

End Structure

I’d like when you make some kind of statement in that style:

Dim objServico as Servico

List all my services the same when we declare a color. An image for better understanding:

Todas as cores são listadas. Porém essas cores não são Enum, e sim Shared Readonly Property

  • Did the answer solve your problem? Do you think you can accept it? If you don’t know how you do it, check out [tour]. This would help a lot to indicate that the solution was useful to you and to give an indication that there was a satisfactory solution. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

1

Accessing members of a class or structure (which gives the same effect with members of a public body) is quite different from accessing static (shared) members of a type. Static members can only be accessed through the type, not the instance, so the IDE won’t even show them. So you can’t access:

objServico.Instalacao

Must be:

Service.Instalacao

Screenshot IDE autocompletion

  • Thank you for your reply. But I’m sure that the example I gave is not an Enumeration, that you can see in the Color Structure documentation: https://msdn.microsoft.com/pt-BR/library/system.drawing.color%28v=vs.110%29.aspx In the documentation you can see that all colors are read-only static properties.

  • It’s true, without the context I thought it was the enumeration Color. I took this part but the answer doesn’t change.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.