VB.NET 中 Property 用法
PublicPropertyhour()AsIntegerGetReturntrkHour.ValueEndGetSet(ByValValueAsInteger)'set...
Public Property hour() As Integer
Get
Return trkHour.Value
End Get
Set(ByVal Value As Integer)
'set the hour...
trkHour.Value = Value
'determine the state..
Dim hour As Integer = Value
If hour >= 6 And hour < 7 Then
CurrentState = DayAction.TravelingToWork
ElseIf hour >= 7 And hour < 8 Then
CurrentState = DayAction.TravelingToWork
ElseIf hour >= 8 And hour < 13 Then
CurrentState = DayAction.AtLunch
ElseIf hour >= 13 And hour < 14 Then
CurrentState = DayAction.AtWork
ElseIf hour >= 14 And hour < 17 Then
CurrentState = DayAction.RelaxingWithFriends
ElseIf hour >= 17 And hour < 18 Then
ElseIf hour >= 18 And hour < 22 Then
CurrentState = DayAction.GettingReadyForBed
Else
CurrentState = DayAction.Asleep
End If
'set the text...
Dim statusText As String
statusText = "At" & Value & ":00,Len is " & CurrentState.ToString
txtState.Text = statusText
End Set
End Property
其中Property、get、set、作用是什么 展开
Get
Return trkHour.Value
End Get
Set(ByVal Value As Integer)
'set the hour...
trkHour.Value = Value
'determine the state..
Dim hour As Integer = Value
If hour >= 6 And hour < 7 Then
CurrentState = DayAction.TravelingToWork
ElseIf hour >= 7 And hour < 8 Then
CurrentState = DayAction.TravelingToWork
ElseIf hour >= 8 And hour < 13 Then
CurrentState = DayAction.AtLunch
ElseIf hour >= 13 And hour < 14 Then
CurrentState = DayAction.AtWork
ElseIf hour >= 14 And hour < 17 Then
CurrentState = DayAction.RelaxingWithFriends
ElseIf hour >= 17 And hour < 18 Then
ElseIf hour >= 18 And hour < 22 Then
CurrentState = DayAction.GettingReadyForBed
Else
CurrentState = DayAction.Asleep
End If
'set the text...
Dim statusText As String
statusText = "At" & Value & ":00,Len is " & CurrentState.ToString
txtState.Text = statusText
End Set
End Property
其中Property、get、set、作用是什么 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询