ASP中Property Let、Property Set、Property Get语句的用法和区别
来源:互联网 发布:信誉好的单车淘宝店 编辑:程序博客网 时间:2024/04/23 18:14
Property Let 是用来设置属性值的。
Property Set 是用来设置对象引用的。
Property Get 是用来获取属性值的。
在这里假设name是类NewsClass的一个属性,调用为set News = new NewsClass
News.name = "news_class" 这里就调用了Public Property Let name这个name属性,let是让用户初始化name变量,一般用来初始化或重新设置类中的变量
set是类中的赋值方法,let和set的区别在于Let针对“变量”,而Set针对“对象、集合”,即Property Set过程是对“对象引用”赋值,Property Let过程只能用于属性赋值
获取属性值都用Property Get
下面是一个应用实例:
Class BookClass
private str_author
'/----class_initialize()是类的初始化事件,调用该类时就会自动调用这一个事件
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.fzic.net.<br/>"
end sub
public property set authorObj(byval value)
end property
End Class
'/----以下是调用范例
set book = new BookClass
book.author = "妫水山庄信息" '调用了property let
set book.rs = new 对象 '调用了property set
response.write book.author '调用property get
book.information '调用了bookclass类中的information过程(方法)
set book = nothing '结束,释放对象
说明:
Property Let和Property Get后的变量名可以相同可以不相同;用Let声明的,调用的是classname.property = "接收值";用Get声明的,调用的是classname.property,一般用response.write classname.property读出它的值
- ASP中Property Let、Property Set、Property Get语句的用法和区别
- ASP中的 class Property Get、Property Let的使用
- FAQ:Property Get、Property Let 和 Property Set 我不太能理解。
- public Property let,get和直接用public什么区别?
- VB Property 中 Set与Let赋值
- class Property Get、Property Let 使用说明
- Get Set Property
- property Get Set方法
- iOS 理解@property和set&get方法
- 使用@property 改变get和set
- @property增强下 set 方法和 get 方法的重写
- OC中@property和@synthesize的用法
- C#中Attribute和Property的区别
- C#中attribute和property的区别
- @property中retain和copy的区别
- dom中attribute和property的区别
- JS中Attribute 和 property的区别
- JS中Attribute 和 property的区别
- oracle lead lag 使用实践
- 系出名门Android(7) - 控件(View)之ZoomControls, Include, VideoView, WebView, RatingBar, Tab, Spinner, Chronometer, ScrollView
- C# C++/CLI 混合编程类型转化注意事项
- 使用truss、strace或ltrace诊断软件的"疑难杂症"
- 开启子线程设置GridVIew数据源
- ASP中Property Let、Property Set、Property Get语句的用法和区别
- public Property let,get和直接用public什么区别?
- Javascript中的Var浅谈
- oracle package
- 系出名门Android(8) - 控件(View)之TextSwitcher, Gallery, ImageSwitcher, GridView, ListView, ExpandableList
- 关于声明()和定义的认识
- Oracle Architectural(Oracle 体系结构)!!!
- VC6编写在windows7下的应用程序以管理员身份加载之一
- 实战RAID5 手把手教你组磁盘阵列 5