Question : Using an Enum to limit the property vales of a class

After a couple of years of programming I've finally discovered the joy of Enum ;-)

And now I'd like to use an Enum to limit the range of values that are possible for a given property in my class.

How is this done?

My code snippet shows what Ive done already but there's no link between the Public Property "OptionName" and the Enum OptionType. How do I force them to work together?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Public Class TicketOption
 
    Private _optionName As Integer
 
    Public Enum OptionType
        Ski = 2
        Golf = 4
        Business = 7
    End Enum
 
    Public Property OptionName() As Integer
        Get
            Return _optionName
        End Get
        Set(ByVal value As Integer)
            _optionName = value
        End Set
    End Property
 
End Class

Answer : Using an Enum to limit the property vales of a class

like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Public Class TicketOption
 
    Private _optionName As OptionType
 
    Public Enum OptionType
        Ski = 2
        Golf = 4
        Business = 7
    End Enum
 
    Public Property OptionName() As OptionType
        Get
            Return _optionName
        End Get
        Set(ByVal value As OptionType)
            _optionName = value
        End Set
    End Property
 
End Class
Random Solutions  
 
programming4us programming4us