What Are Enums In C#?

Enums are a feature of C# which I commonly use while developing games. The most common use is switching between states.


Enums are a value-type variable that declare a list (not a List<>) of named constants. These constants are keywords which can denote a variety of data in different situations.

By creating another variable of the type of the enum which you just created, you can now assign one of the named constants as the variable value.

This is an easy way to keep track of the current state of a behaviour, entity, or class. It can also dictate what code is executed.

The below code uses a Switch statement to change which code is executes, depending on the current value of “movementState”, the variable of type MovementStates

If the “movementState” variable is “public” or “[SerializeField] private”, then it will appear in the Unity Inspector as a dropdown list, and can be changed to any of the defined constants.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vincent Taylor

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.