ALLINSIGHT

Home of the AlmostImplementedException

enum

How to iterate through an enum

On occasions it’s necessary to iterate through an enum. Maybe you need to show all values or names or want to use all values in a unit test. Since .Net 4 there are two ways to get the names and values, but as you will see the old way is the better choice. First of […]

, ,

Bit-Flags with enums

Today i want to show you how to use enumerations to set multiple values in a variable using bit-flags. Normaly enums are an easy way to set a single value and check later which value is set working with a static name throughout your entire application. Enums are much better then magic numbers or constants […]

, , ,

How to convert string to enum

It is good practice to use enums to choose which part of the code should be executed, but sometimes you’ll get a string and have to convert it to an enum. Here is, how you can do it. First, declare a custom enum or use a given one. And then use the Enum.Parse command. This […]

, , ,