Tag: enum
Converting an Enum to Integer in C#
If you need to convert an enum to its numeric equivalent , you can simply cast the values to integer . Below is a sample code snippet that demonstrates how to do it. Converting an Enum to Integer in C#
How to display the string value of a Enum in C# ?
Below is a sample sourcecode that demonstrates how to display the string value of a Enum in C# ?
How to Check if the Enum Value is Defined in C# ?
There are times when it is necessary to check if the constant name or numeric value is defined in the Enum . We can use the Enum.IsDefined method to verify this. How to Check if the Enum Value is Defined in C# ? Below is a sample code to demonstrate how to Check if the Enum Value is Defined in C# using Enum.IsDefined method. The…
Assign value to enum in c#
You can assign the integer value to enum by casting it to the respective enum type. For example , In the below sample program , you can assign the value 10 to enum by casting the value to the Designation type.
How to Convert Enum to Integer in C# ?
Below is a sample sourcecode that demonstrates how to Convert Enum to Integer in C# ?