+ -
当前位置:首页 → 问答吧 → ASP 的CLASS类中 Property Let 和 Property Get 有什么用???

ASP 的CLASS类中 Property Let 和 Property Get 有什么用???

时间:2011-08-16

来源:互联网

设置变量话用 Public var 就可以啊 为什么要用 Property Let var 呢?

还有:
Public Property Get Version 和 Public function Version 的效果是一样的啊。

这到底是怎么一回事呢,请高手解答

作者: niaoxing333   发布时间: 2011-08-16

1 这样可以控制属性只读或者只写
VBScript code

Class A
    Private b
    Public Property Get Version
        Version = b
    End Property
    Public Property Let Version(v)
        b = v
    End Property
End Class

Set x = New A
x.Version = "1"

WScript.Echo x.Version
WScript.Echo x.b ' 不能直接访问



2 属性和方法是不一样
属性了类似于变量的 赋值或取值 ,a.xx = yy , yy = a.xx 
方法是调用 a.b() 或 xx = a.b()

作者: hookee   发布时间: 2011-08-16