当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP关于类的Let,Set和Get的用法的异同

ASP
asp查询xml的代码 不刷新页面查询的方法
ASP 快速执行动态网页
asp实现本周的一周时间列表的代码
asp get和post数据接收过滤
为google量身定做的sitemap生成代码asp版
适合所有网站的rss和xml聚合功能asp代码
ASP MSSQL存储过程的实现小例
动网论坛的asp 数据库连接代码
ASP+MSSQL2000 数据库被批量注入后的解决方法
asp 去掉html中的table正则代码函数
asp 过滤非法字符函数
asp检测是否为中文字符函数
ASP 包含文件中的路径问题和使用单一数据库连接文件的解决方案
asp HTTP 500错误 常见问题分析
asp 关键词高亮显示(不区分大小写)
一段ASP的HTTP_REFERER判断代码
asp datediff 时间相减
asp下去除超链接的函数
asp连接mssql2005的代码
asp access数据库并生成XML文件范例

ASP关于类的Let,Set和Get的用法的异同


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 57 ::
收藏到网摘: n/a

Property Let 是设置变量用的。
Property Set 是设置对象用的。
Property Get是取回属性用的。

在这里name只是这个类的一个属性,比如类名为 NewsClass
调用为 set News = new NewsClass

News.name="news_class" 这里就调用了Public Property Let name 这个name属性,把值传给cache_name_custom
其中cache_name_custom只是这个类中的一个变量。
let是让用户初始化name变量,一般用来初始化或重新设置类变量,
set是类中的赋值方法, let 和set 的区别在于 Let 针对“变量” Set 针对“对象、集合“ ,既Property Set 过程对象引用赋值
Property Let 过程只能用于属性赋值。

取值都用get。

Class BookClass
private str_author
private sub class_initialize() '类初始化,调用类时就会自动调用的一个事件
str_author = "妫水山庄"
end sub
'/----class_terminate()是类的结束事件,只要一退出该类,就会触发该事件.
private sub class_terminate()
response.write "<br/>BookClass结束了<br/>"
end sub

'/----定义类的属性,该属性是返回该类的作者号
public property get author
author = str_author
end property
public property let author(byval value)
str_author = value
end property
'/----该方法返回一个版本信息
public sub information()
response.write "<br/>coding by www.ruanchen.com.<br/>"
end sub

public property set authorObj(byval value)
end property
End Class

'调用:
set book = new BookClass
book.author="妫水山庄信息" '调用了let
'set book.rs=new 对象 '调用了set
response.write book.author '调用get
book.information '调用了bookclass类中的information过程
set book=nothing '结束