I'm trying to writing a method that parses a string parameter into an enum. The enum's type is also determined by a parameter. This is what I've started with:
public static type GetValueOrEmpty(string text, Type type)
{
if (!String.IsNullOrEmpty(text))
{
return (type)Enum.Parse(typeof(type)value);
}
else
{
// Do something else
}
}
Obviously this won't work for a number of reasons. Is there a way this can be done?