ASP关于类的Let,Set和Get的用法的异同
PropertyLet是设置变量用的。
PropertySet是设置对象用的。
PropertyGet是取回属性用的。
在这里name只是这个类的一个属性,比如类名为NewsClass
调用为setNews=newNewsClass
News.name="news_class"这里就调用了PublicPropertyLetname这个name属性,把值传给cache_name_custom
其中cache_name_custom只是这个类中的一个变量。
let是让用户初始化name变量,一般用来初始化或重新设置类变量,
set是类中的赋值方法,let和set的区别在于Let针对“变量”Set针对“对象、集合“,既PropertySet过程对象引用赋值
PropertyLet过程只能用于属性赋值。
取值都用get。
如
ClassBookClass
privatestr_author
privatesubclass_initialize()'类初始化,调用类时就会自动调用的一个事件
str_author="妫水山庄"
endsub
'/----class_terminate()是类的结束事件,只要一退出该类,就会触发该事件.
privatesubclass_terminate()
response.write"
BookClass结束了
"
endsub
'/----定义类的属性,该属性是返回该类的作者号
publicpropertygetauthor
author=str_author
endproperty
publicpropertyletauthor(byvalvalue)
str_author=value
endproperty
'/----该方法返回一个版本信息
publicsubinformation()
response.write"
codingbywww.webjx.com.
>"
endsub
publicpropertysetauthorObj(byvalvalue)
endproperty
EndClass
'调用:
setbook=newBookClass
book.author="妫水山庄信息"'调用了let
'setbook.rs=new对象'调用了set
response.writebook.author'调用get
book.information'调用了bookclass类中的information过程
setbook=nothing'结束