System Library Common Framework
Search Results for

    *.Benchmark*,*.Tests*,*.ApiTests*,*.BaseTest*,DelegateJsonConverter,CalleeCancelledRequestException,ClientResponse,ContentType,OutputCachePolicy
    Show / Hide Table of Contents Show / Hide Table of Contents
    NamespaceSystemLibrary.Common.Framework.Extensions SystemLibrary.Common.Framework.Net.dll

    This class contains extension methods for Enum as a Generic Type

    Remarks
    X

    Current version of C# does not allow extension methods 'generic types', hence these are static methods

    EnumExtensions<TEnum>

    public static class EnumExtensions<TEnum> where TEnum : IComparable, IFormattable, IConvertible

    Inheritance
    object
    EnumExtensions<TEnum>
    Type Parameters
    Name Description
    TEnum
    Examples
    Arguments
    X
    Generic types
    Name Description
    TEnum

    Methods

    Get all keys as the enum value itself

    Remarks
    X

    Current version of C# does not allow extension methods 'generic types', hence these are static methods

    public static IEnumerable<TEnum> GetEnums()

    X
    enum Color 
    {
        [EnumText("Black Colored Text")]
        Black,
        White
    }
    var enums = SystemLibrary.Common.Framework.Extensions.EnumExtesions<Color>.GetEnums();
    
    // enums is now:
    // enums[0] is Color.Black
    // enums[1] is Color.White
    X
    X
    Type Description
    IEnumerable<TEnum>

    IEnumerable of Enum of your choice

    Get all keys in the Enum as an IEnumerable of string

    Remarks
    X

    Current version of C# does not allow extension methods 'generic types', hence these are static methods

    public static IEnumerable<string> GetKeys()

    X
    enum Color 
    {
        [EnumText("Black Colored Text")]
        Black,
        White
    }
    
    var keys = SystemLibrary.Common.Framework.Extensions.EnumExtesions<Color>.GetKeys();
    
    // keys[0] is 'Black'
    // keys[1] is 'White
    // Note: it returns the Keys converted to strings only, ignoring EnumText attribute
    X
    X
    Type Description
    IEnumerable<string>

    Keys as an IEnumerable of string

    This class contains extension methods for Enum as a Generic Type

    Remarks
    X

    Current version of C# does not allow extension methods 'generic types', hence these are static methods

    public static IEnumerable<string> GetValues()

    X
    X
    Type Description
    IEnumerable<string>

    }

    In This Article
    Package: nuget
    Source: github
    Website: System Library Common Framework