Filter by Tags

Get int value from enum in C#



0 0

If we have an enum data type in C#, how can we get the integer value corresponding to the enum value. For example consider the following enum

enum Gender





How to find the integer value corresponding the Female option in this enum ?

Open E-School
Posted on : Sun, Jan 07, 2018
Views : 101

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (1)


In C# we can typecast the enum data member into integer to get its corresponding integer value. For example, in the Gender enum mentioned in the question if we wish to get the integer value corresponding to the Female member of the enum, we can do so by writing the following code

int value = (int)Gender.Female;

For more details please go through the following article

Ravinder Singh
Thu, Jan 18, 2018

Edit Answer

This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp