First of all you create a enum calss and define enum like FontFamily
public static partial class Enums
{
public enum FontFamily
{
/// <summary>
/// The undefined
/// </summary>
Undefined,
/// <summary>
/// The courier
/// </summary>
Courier,
/// <summary>
/// The helvetica
/// </summary>
Helvetica,
/// <summary>
/// The times new roman
/// </summary>
TimesNewRoman,
/// <summary>
/// The symbol
/// </summary>
Symbol
}
}
C# Code convert FontFamily Enums in list type and convert into SelectListItem
List<SelectListItem> fontList = new List<SelectListItem>();
var fontLists = Enum.GetValues(typeof(Enums.FontFamily));
for (int i = 0; i < fontLists.Length; i++)
{
fontList.Add(new SelectListItem { Text = ((Enums.FontFamily[])fontLists)[i].ToString(), Value = ((Enums.FontFamily[])fontLists)[i].ToString() });
}
Comments
Post a Comment