<select id="Locale">
<option selected></option>
@foreach (var enumValue in Enum.GetValues(typeof(Language)))
{
Language language = (Language)enumValue;
FieldInfo fieldInfo = language.GetType().GetField(language.ToString());
object[] attrs = fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), true);
var friendlyName = ((DescriptionAttribute)attrs[0]).Description;
<option value="@enumValue">@friendlyName</option>
}
</select>
No comments:
Post a Comment