In this post I want to present an easy way to cast an int to an enum in C#. It is very easy and straight forward:
From a string:
YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString);
From an int:
YourEnum foo = (YourEnum)yourInt;
That’s all! Have a nice day!