Tag: enum

Enum support in PHP

As any PHP developer knows, there is no native enum support in PHP due to the fact that PHP is a dynamic language where a variable can be anything and everything. Many have tried to implement their own version of enum support, some solutions working better than others. Here, I’ll give you my version of


Tags:


Flags attribute for Enums

If you want to be able to use several of the enum options at once you can use the FLAGS attribute when declaring the enum. [Flags] public enum AccessRights : short { READ = 1, WRITE = 2, EXECUTE = 4 } To make it work you need to enumerate the fields in powers of




Enums in C#

An enum is a defined set of constants in a list. If you don’t give the enums any values they will start with 0 and count up. In this example we’ve forced the count up to start with 1. public enum SingleColors { RED = 1, GREEN, BLUE, YELLOW } You can change the type


Tags:


%d bloggers like this: