Enumerations

This is the first of a series of posts about C#. Since I can’t really think of tiny apps to put stuff that I’ve learned to practice, the least I can do is blog about it, hopefully to boost my memory on it. So let’s get on with it..

In short, an enumeration is a user-defined interger type. Let’s say you want to define the colors of a traffic light. Defining them with strings has it’s associated overheads. The most memory-efficient way is to use integers to represent the colors: say, 1 for red, 2 for yellow, 3 for green. Problem is, the numbes 1, 2 and 3 aren’t really self-explaining. One might mistake 3 for red for example. The next best way is to use some constants: Read the rest of this entry »

Tags: ,