How to get an Enum member given its integer value.

 Posted by vishalneeraj-24503 on 8/5/2014 | Category: Visual Studio Interview questions | Views: 569 | Points: 40
Answer:

'VB.Net
Dim enum_obj As Active_Inactive

Dim value As Integer = 1
enum_obj = CType(value,Active_Inactive)
MasBox(enum_obj.ToString())

//C#
Active_Inactive enum_obj;

int value = 1;
enum_obj = (Active_Inactive)value;
MessageBox.Show(enum_obj.ToString());


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response