Table of Contents

Class EnumDescriptionExtensions

Namespace
HeroKit.Enums
Assembly
HeroKit.dll

Reads display texts of enum values.

public static class EnumDescriptionExtensions
Inheritance
EnumDescriptionExtensions
Inherited Members

Methods

GetDescription<T>(T)

Returns the display text of an enum value from DescriptionAttribute or DisplayAttribute.

public static string GetDescription<T>(this T value) where T : struct, Enum

Parameters

value T

The enum value.

Returns

string

The description, the display name or the member name.

Type Parameters

T

The enum type.

Examples

enum OrderStatus { [Description("Kargoya verildi")] Shipped }
OrderStatus.Shipped.GetDescription(); // "Kargoya verildi"

Remarks

DescriptionAttribute wins over Name. Values without either attribute, and combined flag values, return their name.