IW4M-Admin/SharedLibraryCore/Helpers/ParseEnum.cs

21 lines
381 B
C#
Raw Normal View History

using System;
2018-04-08 02:44:42 -04:00
namespace SharedLibraryCore.Helpers
{
public class ParseEnum<T>
{
public static T Get(string e, Type type)
{
try
{
return (T)Enum.Parse(type, e);
}
catch (Exception)
{
return (T)(Enum.GetValues(type).GetValue(0));
}
}
}
}