Cast int to enum in C# – Programming, Pseudocode Example, C# Programming Example

Cast int to enum in C#

This post describes how can we convert enum into different data types. These are very often used operation. This is very simple to achieve thing.

Let take an exmaple

enum to int

To convert a enum to interger simply type cast the enum into integer

int to enum

Same like above, simply type cast the integer to enum

string to enum

If you have string value and you want to type cast that into enum, then you can use Enum.Parse

enum to string

This is the simplest one, just use the ToString method of the enum


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.