Enum

suggest change

Introduction

An enum's underlying type can be byte, sbyte, short, ushort, int, uint, long, ulong, or char. The default is int, and it can be changed in the enum definition:

public enum Weekday : byte { Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5 }

This is useful when P/Invoking to native code, mapping to data sources, and similar circumstances. In general, the default int should be used, because most developers expect an enum to be an int.

Syntax

Remarks

An Enum (short for “enumerated type”) is a type consisting of a set of named constants, represented by a type-specific identifier.

Enums are most useful for representing concepts that have a (usually small) number of possible discrete values. For example, they can be used to represent a day of the week or a month of the year. They can also be used as flags, which can be combined or tested with bitwise operations.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents