Base Type for Enums

You want to know when it’s okay to specify the base type for an enumeration.

As a general rule, you should avoid specifying a base type for enums. Instead, rely on the default Int32 base type.

There is an exception, of course. You may have a justified reason to specify a non-default base type. For example, let’s say you plan on creating large arrays of enum values. In this case, it’s perfectly valid to use Byte or Int16 as the base type. Just be sure, however, to never use a non-CLS-compliant integer type, like UInt32 or UInt64, as the base type.


// Using a 16-bit enum to save memory.
public enum Authorization : short {

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s