在DotNetNuke.UI.Utilities.ClientAPI中有这样一个Property:
Private Shared ReadOnly Property ClientVariableControl(ByVal objPage As Page) As HtmlInputHidden
Get
Dim ctlVar As HtmlInputHidden = CType(DotNetNuke.UI.Utilities.Globals.FindControlRecursive(objPage, "__dnnVariable"), HtmlInputHidden)
If ctlVar Is Nothing Then
Dim ctlParent As Control 'error prone... should put placeholder in page
ctlParent = objPage.Controls(0)
ctlVar = New HtmlInputHidden
ctlVar.ID = "__dnnVariable"
ctlParent.Controls.Add(ctlVar)
End If
Return ctlVar
End Get
End Property
它是个只读Property,而且还提供了一个参数。这我就有点不明白了。
这样的property和普通的方法有什么不同,为什么要写成property。那C#中对property来理解,好像还无法把这段代码转换成C#property,因为有参数。