using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SuperSocket.Common
{
///
/// String extension
///
public static partial class StringExtension
{
///
/// Tries to parse string to enum type.
///
///
/// The value.
/// if set to true [ignore case].
/// The enum value.
///
public static bool TryParseEnum(this string value, bool ignoreCase, out T enumValue)
where T : struct
{
try
{
enumValue = (T)System.Enum.Parse(typeof(T), value, ignoreCase);
return true;
}
catch
{
enumValue = default(T);
return false;
}
}
}
}