Class EnumExtensions
Enum 扩展方法
Inherited Members
Namespace: Lett.Extensions
Assembly: Lett.Extensions.dll
Syntax
public static class EnumExtensionsMethods
| Improve this Doc View SourceGetDescription(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 |