Answer: 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
'VB.Net
enum_obj = CType(System.ComponentModel.TypeDescriptor.GetConverter(enum_obj).ConvertFrom("Active"),Active_Inactive)
MasBox(enum_obj.ToString())
//C#
enum_obj = (Active_Inactive)TypeDescriptor.GetConverter(enum_obj).ConvertFrom("Active");
MessageBox.Show(enum_obj.ToString());
Asked In: Many Interviews |
Alert Moderator