All posts with Tag enum

Preview image blogpost

Enum.TryParse unexpected behavior

Enums are very simple structures, but some functions like Enum.TryParse can have unexpected behavior. In this short blog post, we discover why and what are the alternatives.

Read the whole article

Preview image blogpost

A better enumeration - Type safe from start to end

Enumerations are one of the fundamental value types in C#. enum's are handy if you have a constrained set of allowed values. But the enum type also has a lot of drawbacks. Personally, one major issue for me is that you can't define methods inside the enum. Plus, you can just pass them invalid values and it just works (Todd Howard I'm looking at you).

So why not make a lightweight alternative which removes a lot of the shortcomings of an enum?

Read the whole article

An error has occurred. This application may no longer respond until reloaded. Reload x