Instead, I would use an enumeration:
public enum DifficultyLevel { Easy = 0, Medium = 1, Hard = 2 }
Thus, all values โโare defined in a structure that is well defined as being associated with a type, and not as free constants that can be associated with anything.
Declare your personal field as:
private DifficultyLevel _difficulty;
Assign a value similar to this:
_difficulty = DifficultyLevel.Easy;
By specifying the numerical values โโfor the enumeration, you can also convert them to known values โโof integer values โโand from them, if you need:
_difficulty = (DifficultyLevel)1; int level = (int)_difficulty;
Guffa source share