Show / Hide Table of Contents

    Class EnumExtensions

    Enum 扩展方法

    Inheritance
    Object
    EnumExtensions
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Lett.Extensions
    Assembly: Lett.Extensions.dll
    Syntax
    public static class EnumExtensions

    Methods

    | Improve this Doc View Source

    GetDescription(Enum)

    获取枚举描述

    需要在枚举中加入 Description 属性

    示例
    

    private enum MyEnum { [Description("这里是EnumValue0的描述")] EnumValue0 = 0, }

    Declaration
    public static string GetDescription(this Enum this)
    Parameters
    Type Name Description
    Enum this
    Returns
    Type Description
    String

    获取失败时 返回null

    Examples
    var rs = MyEnum.EnumValue0.GetDescription(); // rs == "这里是EnumValue0的描述" 
    Exceptions
    Type Condition
    ArgumentNullException
    ArgumentException
    NotSupportedException
    AmbiguousMatchException
    TypeLoadException
    • Improve this Doc
    • View Source
    Back to top Copyright (c) 2019 viacooky. All rights reserved.