O'Reilly logo

Visual Basic® .NET by Example by Bob Donald, Gabriel Oancea

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

Enumerations

Let's assume you have been given the task of writing a subsystem for a game of cards (like bridge, for example). Your task is to determine if a given card from the deck was used already. That means you need some means to represent the deck of cards and remember for each card if it was used or not. A deck of cards consists of 52 cards divided into 4 suits (clubs, diamonds, hearts, and spades). Each suit consists of the cards from 2 to 10, the Jack, Queen, King, and Ace of the suit.

To store the fact that a card was used you can use an array of 52 Boolean values. Or even better (more intuitive) you could use a two-dimensional array of 4 rows (one per suit) and 13 columns (one for each card in the suit). Deciding that you use the latter ...

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