public
创新互联于2013年开始,是专业互联网技术服务公司,拥有项目网站设计、成都网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元新建做网站,已为上家服务,为新建各地企业和个人服务,联系电话:18980820575
structure
struc
public
name
as
string
public
shengao
as
integer
……
end
structure
public
items
as
struc()
readonly
property
people(argname
as
string)
as
struc
get
for
each
i
as
struc
in
items
if
i.name=argname
then
reture
i
next
end
get
end
property
struc可以用class,property可以用function,people通过参数返回一个对象,对象可以来源于某个数组的某个元素,也可以是其他来源。
people也可以是类的
构造方法
,而shengao等是类的成员,但你的写法是错误的,构造方法必须用new
实例化
当父类构造函数有多个重载时,不加base
则自动匹配父类无参数的构造函数;base()关键字可以显示地指定参数以匹配父类的构造函数;EG:
class
people
{
public
string
str
=
"moren";
public
people(string
s)
{
this.str
=
s;
Console.WriteLine(this.str);
}
public
people()
{
Console.WriteLine(str);
}
}
class
me
:
people
{
public
me()
{
Console.WriteLine("me子类");
}
}
class
you
:
people
{
public
you()
:
base("you子类")
{
Console.WriteLine("you子类");
}
}
static
void
Main(string[]
args)
{
string
str
=
"main";
me
me1
=
new
me();
Console.WriteLine("===============================");
you
you1
=
new
you();
Console.Read();
结果:
moren
me子类
===============================
you子类
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) ;
这样就行了,希望我的回答可以帮助你!