EnumExtension..::..GetDescription Method (Enum)
Gets the description.
Namespace:
AdvantageCMS.Core.Common.ExtensionAssembly: AdvantageCMS.Core (in AdvantageCMS.Core.dll)
Syntax
Parameters
- genericEnum
- Type: Enum
The generic enum.
Return Value
String description of enumeration valueExamples
Example of retrieving description based on culture codes and enum attribute tags
C#
public enum eExampleEnum { //Returns back the name of the enum (None) None = 0, //you can use partial culture codes! [LocalDescription("en", "Good Entry"), LocalDescription("fr", "Bonne entrée")] Good = 1, //If spanish, it will pickup the Localized entry, otherwise default [Description("Bad Entry")] [LocalDescription("es", "Mala entrada")] Bad = 2, //Will always return the LocalDescription when English...Other culture codes return default [Description("Default Entry")] [LocalDescription("en", "Entry English")] Entry = 3 } // Culture code : en-US var noneString1 = eExampleEnum.None.GetDescription(); //Returns Enum.ToString() -- "None" var goodString1 = eExampleEnum.Good.GetDescription(); // Returns based on culture code -- "Good Entry" var badString1 = eExampleEnum.Bad.GetDescription(); // Returns default description -- "Bad Entry" var entryString1 = eExampleEnum.Entry.GetDescription(); //Returns base on culture code -- "Entry English" var badEsCodeString1 = eExampleEnum.Bad.GetDescription("es-MX"); //Override the current culture to return "Mala entrada" // Culture code : es-MX var noneString2 = eExampleEnum.None.GetDescription(); //Returns Enum.ToString() -- "None" var goodString2 = eExampleEnum.Good.GetDescription(); // Returns Enum.ToString() -- "Good" var badString2 = eExampleEnum.Bad.GetDescription(); // Returns based on culture code -- "Mala entrada" var entryString2 = eExampleEnum.Entry.GetDescription(); Returns Enum.ToString() -- "Entry" var badEsCodeString2 = eExampleEnum.Bad.GetDescription("es-MX"); //Override the current culture to return "Mala entrada"