| ·隐式类型本地变量 | ·对象和集合对象初始化 |
| ·匿名类型 | ·深层次的XML支持 |
| ·综合查询 | ·扩展方法 |
| ·嵌套函数 | ·空类型 |
| ·非严格委托 | ·动态接口 |
| ·动态标识符 |
| Class Country Public Property Name As String Public Property Area As Float Public Property Population As Integer End Class |
| Dim Countries = _ { new Country{ _ .Name = "Palau", .Area = 458, .Population = 16952 },_ new Country{ _ .Name = "Monaco", .Area = 1.9, .Population = 31719 },_ new Country{ _ .Name = "Belize", .Area = 22960, .Population = 219296 },_ new Country{ _ .Name = "Madagascar", .Area = 587040, .Population = 13670507 } _ } |
| Dim SmallCountries = Select Country _ From Country In Countries _ Where Country.Population < 1000000 For Each Country As Country In SmallCountries Console.WriteLine(Country.Name) Next |
| PalauMonacoBelize |
| Dim Countries = _ { new County { .Name = "Palau", .Area = 458, .Population = 16952 }, _ ... _ } |
| Dim Countries As Country() = {...} |
| Dim SmallCountries = Select Country _ From Country In Countries _ Where Country.Population < 1000000 |
| Function F(Country As Country) As Boolean Return Country.Population < 1000000 End FunctionDim SmallCountries As IEnumerable(Of Country) = _ Countries.Where(AddressOf F) |
这个扩展的表达式把编译器产生的本地函数作为一个委托Addressof F传递给表达式函数Where,Where在标准的查询操作库里定义为一个IEnumerable(of T)接口扩展。
下面我们对VB9的特性做一个深入的探究。
[1] [2] [3] [4] [5] [6] [7] 下一页