博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Collections
阅读量:5074 次
发布时间:2019-06-12

本文共 1551 字,大约阅读时间需要 5 分钟。

VB.NET supports collections such as List and Dictionary, which are useful constructs when building applications that need to access a set of related information.

When building Lists containing objects, the Of keyword is used in the definition.
New elements are added to the List using its Add method.
                       
Dictionary collections work similarly to Lists with the addition of a "key" portion to each element.
The data type KeyValuePair is useful when iterating through a Dictionary collection as the example below demonstrates.
The Dictionary method ContainsKey returns true if the parameter is found as a key value in the Dictionary object.
The Collections' Count property returns an Integer containing the number of members in the collection.
The Item method returns the member of the collection for the specified key.

Dim animal As Animal

animal = Zoo.Item(0) ' return the first animal in the Zoo List

The Remove method removes a member from a collection.

Zoo.Remove(animal) ' remove the first animal in the Zoo List (see above)

The following will not work because the new animal object is not an Animal object that is directly referenced within the Zoo List (even though it is defined the same)

animal = New Animal( "lion", "roar")

Zoo. Remove( animal)

The RemoveAt method removes a member from a collection at a specified index.

Zoo. RemoveAt(0) ' remove the current first animal in the Zoo List

Collections also support methods Sort and Reverse.

MSDN: Example using the Dictionary collection in VB

 

转载于:https://www.cnblogs.com/dasonandeli/p/4583335.html

你可能感兴趣的文章
jsonp的理解
查看>>
业界水平这么烂吗?
查看>>
android studio 快捷键
查看>>
redis之如何配置jedisPool参数
查看>>
数据结构 一元多项式的加法与乘法
查看>>
百分比与小数的转换
查看>>
SQL优化:对报表生成工具的改进
查看>>
fedora18安装N卡官网驱动
查看>>
使用Dynamics 365 CE Web API查询数据加点料及选项集字段常用查询
查看>>
angular 的ng-view,ngrouter
查看>>
第一次使用博客园
查看>>
Python基础篇【第四篇】:循环语句
查看>>
POJ 2253 Frogger(Dijkstra)
查看>>
contest10 CF544 div2 + ZOJ3705 oooxxo ooooxo ooooxo
查看>>
HTML5 WebSocket
查看>>
android区分模拟器和真机
查看>>
The Swiss Army Knife of Data Structures … in C#
查看>>
android背景选择器selector用法汇总
查看>>
gdb使用笔记 2015-04-11 19:55 32人阅读 评论(0) 收藏...
查看>>
leetCode(23):Binary Tree Zigzag Level Order Traversal ...
查看>>