How to retrieve an Enum member by their Name?

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

To retrieve an Enum member given by their Name,we will use the ConvertFrom() method of the TypeConverter class and cast the result to our Enum type as

enum_obj = CType(System.ComponentModel.TypeDescriptor.GetConverter(enum_obj).ConvertFrom("Active"),Active_Inactive)


enum_obj = (Active_Inactive)TypeDescriptor.GetConverter(enum_obj).ConvertFrom("Active");


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response