Skip to main content

Overview

Collections are a way of managing a group of similar data, such as a list of objects. Visual Studio uses collections to manage such things as the forms in your program, the fields in a table, and the printers available to the system.

Collections are an advanced form of arrays. Arrays are very simplistic because they are filled upon initialization, they have to be manually resized, an element’s index is fixed, and the items are indexed with integers. Collections are an improvement because the elements aren’t automatically created when the array is initialized, they automatically resize themselves, the elements within the collection are dynamic, and they can be referenced with keys.

.NET has a System.Collections namespace containing interfaces and classes that define various collections of objects. These collections consist of lists, queues, arrays, hash tables, and dictionaries. This chapter focuses on the Hashtable class because it is a general-purpose collection that serves most needs and it is very similar to the VB 6.0 Collection class.

VB .NET also uses a special class called Collection that has identical syntax to the VB 6.0 Collection class. We can assume it was added to make migrating VB 6.0 programs easier. C# doesn’t have access to it, but this isn’t necessary because C# can use the more sophisticated namespaces in .NET.

This chapter examines declaring a collection and manipulating its elements. At the end of the chapter, Table 16-2 summarizes the different .NET collection classes that you can explore with MSDN.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 19.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 29.95
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2002 Brian Bischof

About this chapter

Cite this chapter

Bischof, B. (2002). Collections. In: The .NET Languages: A Quick Translation Guide. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-1136-5_16

Download citation

  • DOI: https://doi.org/10.1007/978-1-4302-1136-5_16

  • Publisher Name: Apress, Berkeley, CA

  • Print ISBN: 978-1-893115-48-4

  • Online ISBN: 978-1-4302-1136-5

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics