类的初始化操作,定义变量
2007-01-25 17:42
316 查看
Imports System.Web.Mail
Partial Class _Default
Inherits System.Web.UI.Page
Public Class person
Public Sub New()
_eyecolor = "黑色的"
_name = "鸿运网络科技"
End Sub
Private _name As String
Private _age As Integer
Private _eyecolor As String
Public Property name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property age() As String
Get
Return _age
End Get
Set(ByVal value As String)
If value < 1 Then
value = 1
End If
_age = value
End Set
End Property
Public ReadOnly Property eyecolor() As String
Get
Return _eyecolor
End Get
End Property
End Class
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myperson As New person
myperson.age = "0"
Label1.Text = myperson.name
Label2.Text = myperson.age
Label3.Text = myperson.eyecolor
End Sub
End Class
Partial Class _Default
Inherits System.Web.UI.Page
Public Class person
Public Sub New()
_eyecolor = "黑色的"
_name = "鸿运网络科技"
End Sub
Private _name As String
Private _age As Integer
Private _eyecolor As String
Public Property name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property age() As String
Get
Return _age
End Get
Set(ByVal value As String)
If value < 1 Then
value = 1
End If
_age = value
End Set
End Property
Public ReadOnly Property eyecolor() As String
Get
Return _eyecolor
End Get
End Property
End Class
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim myperson As New person
myperson.age = "0"
Label1.Text = myperson.name
Label2.Text = myperson.age
Label3.Text = myperson.eyecolor
End Sub
End Class
相关文章推荐
- 实现简单通讯录操作。 1、定义联系人类AddressPerson。实例变量:姓名、性别、电话号码、住址、分组名称。方法:自定义初始化方法(姓名、电话号码)、显示联系人信息 2、在main.m中定义可变
- 第一题 定义分数(Fraction)类: 1、成员变量:分子、分母 2、方法: (1)自定义初始化方法(初始分子和分母) (2)分子的赋值、取值方法 (3)分母的赋值取值方法 (4)打印分数信息
- 顺序栈的定义、初始化、出栈、入栈等操作 C++代码实现 ——感想
- 线性表的单链表的定义、初始化等操作
- C++类特殊成员变量(引用、静态、常成员变量)的初始化操作
- Java中定义实例变量时指定初始化值顺序
- 关于C++ 类数据成员初始化的一点总结【为什么类定义中不能初始化成员变量】
- Java数组概述、定义格式说明、初始化、内存分配及常见操作
- Asp.net单页面操作的全局变量ViewState的定义
- keril中不能定义全局变量时初始化的原因
- 变量的定义,初始化和声明
- JavaScript中关于变量初始化和变量未定义
- 变量的初始化与赋值操作无效
- C标签定义变量,做加减乘除操作
- 变量初始化,声明和定义
- (二)GoLang小记 —— 变量的定义与初始化
- 变量只能在定义时被初始化
- 栈的链式存储的定义、初始化、判断空、入栈、出栈、读取栈顶元素、求栈长度、清空栈操作
- effective C++笔记之条款31、32: 千万不要返回局部对象的引用,也不要返回函数内部用new初始化的指针所指对象的引用、尽可能地推迟变量的定义
- GD32F130FXP6学习笔记十二:mdk定义一些变量上电不初始化