Enumerations - Fields Properties or Methods?

  • Thread starter Thread starter Mike
  • Start date Start date
Hi.  If I have a class with a Public Enum, is that Enum a Field, Property, or
Method?  

An Enum is an Enum. It's a definition of a type that contains a bunch
of constant values. So, it's no different for say an integer, in that
it can essentially be a field - though, it can be returned from a
method or property.
 
Hi. If I have a class with a Public Enum, is that Enum a Field, Property, or
Method?

None of the above. It's an Enum. An Enum is a collection of values.
A Field or Property is something that has a value, and a Method is
code that executes.

Public Class SomeClass
Private m_someProperty As SomeEnum
Private m_otherValue As SomeEnum

Public SomeField As SomeEnum

Public Property SomeProperty() As SomeEnum
Get
Return m_someProperty
End Get
Set(value As SomeEnum
m_someProperty = value
End Set
End Property

Public Sub SomeMethod(val As SomeEnum)
m_otherValue = val
End Sub

Public Enum SomeEnum
Value1
Value2
End Enum

End Class

SomeEnum is an Enum.
SomeField is a Field.
SomeProperty is a Property
SomeMethod is a Method.

Dim x As New SomeClass
x.SomeField = SomeClass.SomeEnum.Value2
 
Mike said:
Hi. If I have a class with a Public Enum, is that Enum a Field, Property,
or
Method?

It's none of the above, it's a nested type.
 
Back
Top