O'Reilly logo

Professional C# 6 and .NET Core 1.0 by Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12 Special Collections

What’s In This Chapter?

  • Using bit arrays and bit vectors
  • Using Observable Collections
  • Using immutable collections
  • Using concurrent collections

Wrox.com Code Downloads for This Chapter

The wrox.com code downloads for this chapter are found at http://www.wrox.com/go/professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • BitArray Sample
  • BitVector Sample
  • Observable Collection Sample
  • Immutable Collections Sample
  • Pipeline Sample

Overview

Chapter 11, “Collections,” covers lists, queues, stacks, dictionaries, and linked lists. This chapter continues with special collections, such as collections for dealing with bits, collections that can be observed when changed, collections that cannot be changed, and collections that can be accessed from multiple threads simultaneously.

Working with Bits

If you need to deal with a number of bits, you can use the class BitArray and the struct BitVector32 . BitArray is located in the namespace System.Collections, and BitVector32 is in the namespace System.Collections.Specialized. The most important difference between these two types is that BitArray is resizable—which is useful if you don’t have advance knowledge of the number of bits needed—and it can contain a large number of bits. BitVector32 is stack-based and therefore faster. BitVector32 contains only 32 bits, which are stored in an integer.

BitArray

The class BitArray is a reference type that contains ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required