#T#VB.NET有很多值得学习的地方,这里我们主要介绍VB.NET对象列表。***步是要创建一个同用列表,你可以从多种途径获取数据,但是最简单的方法是添加。文本中,我们会编写代码以便为举例中的集来分类。因此,下面我们就来讲讲创建集的代码。首先,我需要一个能代表集中的bottle的对象。为此而编写的代码是完全符合标准的,而且事实上,vb.net 2008 express intellisense会为你写好大部分的代码。以下是我的VB.NET对象列表:
public class bottle "internalproperties"public property brand() as string
public property name() as string
public property category() as string
public property size() as decimal
public sub new( _
end sub
end class
为了创建集,我需要添加项目:
dim cabinet as list(of bottle) = _ "new list(of bottle)cabinet.add(new bottle( _
"castle creek", _
"uintah blanc", _
"wine", 750))
cabinet.add(new bottle( _
"zion canyon brewing company", _
"springdale amber ale", _
"beer", 355))
cabinet.add(new bottle( _
"spanish valley vineyards", _
"syrah", _
"wine", 750))
cabinet.add(new bottle( _
"wasatch beers", _
"polygamy porter", _
"beer", 355))cabinet.add(new bottle( _
"squatters beer", _
"provo girl pilsner", _
"beer", 355))
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
所有的这些都是vb.net1.0中的标准代码。但是,要通过定义我们自己的bottle对象来注明。我们会在相同集中的多类型中获益,大家把VB.NET对象列表的例子记下来吧。