public
structure
struc
name
as
string
shengao
integer
......
end
items
struc()
readonly
property
people(argname
string)
get
for
each
i
in
if
i.name=argname
then
reture
next
people也可以是类的
构造方法
,而shengao等是类的成员,但你的写法是错误的,构造方法必须用new
实例化
当父类构造函数有多个重载时,不加base
则自动匹配父类无参数的构造函数;base()关键字可以显示地指定参数以匹配父类的构造函数;EG:
class
people
{
str
=
"moren";
people(string
s)
this.str
s;
Console.WriteLine(this.str);
}
people()
Console.WriteLine(str);
me
:
me()
Console.WriteLine("me子类");
you
you()
base("you子类")
Console.WriteLine("you子类");
static
void
Main(string[]
args)
"main";
me1
new
me();
Console.WriteLine("===============================");
you1
you();
Console.Read();
结果:
moren
me子类
===============================
you子类
另外,虚机团上产品团购,超级便宜
你可以直接写Public Sub New(ByVal name As String, ByVal price As Double,byval haskdisk as boolean)
,但在写这句之前要先引用父类的构造函数, 就是加上一句怕你不明白,完整的写法就是这样:
mybase(name , price);
Public Sub New(ByVal name As String, ByVal price As Double,byval haskdisk as boolean) ;
这样就行了,希望我的回答可以帮助你!
以上就是土嘎嘎小编为大家整理的vb.net中类构造函数相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!