mk.helpers
Search Results for

    Show / Hide Table of Contents

    Class EnumHelper

    Provides utility methods for working with enumerations.

    Inheritance
    object
    EnumHelper
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: mk.helpers
    Assembly: mk.helpers.dll
    Syntax
    public static class EnumHelper

    Methods

    Parse<T>(string)

    Parses a string representation of an enumeration value to its corresponding enumeration value.

    Declaration
    public static T Parse<T>(string text) where T : struct, IConvertible
    Parameters
    Type Name Description
    string text

    The string representation of the enumeration value to parse.

    Returns
    Type Description
    T

    The parsed enumeration value.

    Type Parameters
    Name Description
    T

    The type of the enumeration.

    Remarks

    This method attempts to parse the input text into the specified enumeration type. It supports variations in formatting such as underscores and spaces, and attempts to match the case-insensitive enum member names.

    TryParse<T>(string, out T)

    Tries to parse a string representation of an enumeration value to its corresponding enumeration value.

    Declaration
    public static bool TryParse<T>(string text, out T result) where T : struct, IConvertible
    Parameters
    Type Name Description
    string text

    The string representation of the enumeration value to parse.

    T result

    When this method returns, contains the parsed enumeration value if the parsing was successful.

    Returns
    Type Description
    bool

    true if the parsing was successful; otherwise, false.

    Type Parameters
    Name Description
    T

    The type of the enumeration.

    Remarks

    This method attempts to parse the input text into the specified enumeration type. It supports variations in formatting such as underscores and spaces, and attempts to match the case-insensitive enum member names.

    In this article
    Back to top mk.helpers - MIT License