Here's another tip which is a wrapper to retrieve the value from an enum by it's text and also to get the text of an enum based on a value.
public static string RetrieveEnumTextByValue (Type enumType, Object value)
{
if (enumType.IsEnum)
if (System.Enum.GetName(enumType,value) != null)
return System.Enum.GetName(enumType, value);
}
return "";
public static int RetrieveEnumValueByText(Type enumType, string text)
if (System.Enum.Parse(enumType,text) != null)
return Convert.ToInt32(System.Enum.Parse(enumType, text));
return -1;
I'm a little lazy tonight, but maybe I will come in later and post usage. I'll make a better effort to do that in the future, but I have to be up in a few hours, and being tired tomorrow just won't do!
-- Daryl
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, © Copyright 2010
E-mail