求解读语句
Private ReadOnly Property CurrentBrowser() As AxWebBrowser
Get
Return TryCast(CurrentTab.Tag, BrowserData).Browser
求解读以上的语句。
End Get
End Property
CurrentTab.Tag,应该是当前激活的tabpage。
Private Class BrowserData
Public Browser As AxWebBrowser
Public PrevEnabled As Boolean
Public NextEnabled As Boolean
Public Status As String = String.Empty
Public Title As String = String.Empty
Public Address As String = String.Empty
Public IsDownloading As Boolean = False
Public ProgressMax As Integer = 100
Public ProgressValue As Integer = 10
Public Sub New(browser__1 As AxWebBrowser, prevEnabled__2 As Boolean, nextEnabled__3 As Boolean)
Browser = browser__1
PrevEnabled = prevEnabled__2
NextEnabled = nextEnabled__3
End Sub
End Class
还有,我一直不明白的是,属性和变量有啥不同,我直接赋值变量不是比使用属性更简便吗?
[解决办法]
属性比变量灵活
你可以理解 属性=变量+变化
比如
dim a as int
dim b as int
但是属性可以这样
Private Property c() As int
return a+b
end Property
我写的比较简单 实际上可以更复杂 灵活 常用的 比如判断 是否负责取值范围 什么的
[解决办法]
Private ReadOnly Property CurrentBrowser() As AxWebBrowser
定义了一个只读的属性,返回当前的WebBrowser控件。
Get
Return TryCast(CurrentTab.Tag, BrowserData).Browser
将CurrentTab.Tag转换为BrowserData类型,并且取其中的Browser属性或者字段,返回。