/// <summary> /// Converts a string representation into an enum value or indicates that it cannot. /// Accepts both integer formats in string form ([-+][digits]) or names. /// </summary> /// <param name="value">The string representation to convert.</param> /// <param name="ignoreCase">Indicates whether case should be ignored in conversion.</param> /// <param name="policy">Indicates whether invalid integral values should be returned in enum form or should be an error.</param> /// <param name="result">The enum value to initialize based on the parse rules.</param> /// <returns>true if the enum value is successfully parsed, false otherwise.</returns> /// <exception cref="AmbiguousEnumException"><paramref name="ignoreCase"/> is specified and multiple enum members match the specified value.</exception> /// <exception cref="System.ArgumentException"> /// <paramref name="value"/> is blank or whitespace-only. /// <paramref name="policy"/> contains a value not defined by the enum. /// </exception> /// <exception cref="System.ArgumentNullException"><paramref name="value"/> is null.</exception> /// <exception cref="System.InvalidOperationException"><paramref name="value"/> contains flags but the enum is not a <see cref="System.FlagsAttribute"/> enum.</exception> public static bool TryParse <TValue>(string value, bool ignoreCase, InvalidEnumPolicy policy, out TValue result) where TValue : struct, IComparable { return(EnumExt <TValue> .TryParse(value, ignoreCase, policy, out result)); }
/// <summary> /// Converts a string representation into an enum value or indicates that it cannot. /// Accepts both integer formats in string form ([-+][digits]) or names. /// </summary> /// <param name="value">The string representation to convert.</param> /// <param name="result">The enum value to initialize based on the parse rules.</param> /// <returns>true if the enum value is successfully parsed, false otherwise.</returns> /// <exception cref="System.ArgumentException"><paramref name="value"/> is blank or whitespace-only.</exception> /// <exception cref="System.ArgumentNullException"><paramref name="value"/> is null.</exception> /// <exception cref="System.InvalidOperationException"><paramref name="value"/> contains flags but the enum is not a <see cref="System.FlagsAttribute"/> enum.</exception> public static bool TryParse <TValue>(string value, out TValue result) where TValue : struct, IComparable { return(EnumExt <TValue> .TryParse(value, out result)); }