Tips and Hints on Using Collections

Depending on the nature of the problem you are trying to solve, different approaches can be considered as optimal, with collections as well as with other software problems. We try to address a few typical scenarios in the following list:

  • Small/medium collection, does not change much (no items added or removed) after it is created, no searches. Use a regular Visual Basic .NET array. If you need to expose it to client objects, use ArrayList and get the clients a read-only copy.

  • Small/medium collection, does change (many items added or removed) after it is created, no searches. Use an ArrayList or a custom collection derived from it, if the additions are always at the end. If you expect many inserts and removes, ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.