Here i am showing how to get value from an Enum Item
/// <summary>
/// GetDescriptionFromEnumValue is returns the name or value for an Enum Item
/// </summary>
/// <param name="value">Enum Value</param>
/// <returns>Description For Enum</returns>
public static int GetValueFromEnum(Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
int val = (int)fi.GetValue(value);
return val;
}
Use this method
-----------------
objtblLog.LogType = EnumUtility.GetValueFromEnum((Logtype)Session.ErrorLogtype);
Where Session.ErrorLogtype is an integer value
Thanks to my Project manager , who guide me lot to know these things and how to handle a project to get better performance ... "Thank you Sir"
/// <summary>
/// GetDescriptionFromEnumValue is returns the name or value for an Enum Item
/// </summary>
/// <param name="value">Enum Value</param>
/// <returns>Description For Enum</returns>
public static int GetValueFromEnum(Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
int val = (int)fi.GetValue(value);
return val;
}
Use this method
-----------------
objtblLog.LogType = EnumUtility.GetValueFromEnum((Logtype)Session.ErrorLogtype);
Where Session.ErrorLogtype is an integer value
Thanks to my Project manager , who guide me lot to know these things and how to handle a project to get better performance ... "Thank you Sir"
No comments:
Post a Comment