I've found a topic in Here which is about how you could create a drop-down list from an enum in MVC. Here's the answer in that topic:
Martin Faartoft says:
I rolled Rune's answer into an extension method:
public static SelectList ToSelectList<TEnum>(this TEnum enumObj)
{
var values = from TEnum e in Enum.GetValues(typeof(TEnum))
select new { Id = e, Name = e.ToString() };
return new SelectList(values, "Id", "Name", enumObj);
}
I exactly need to do this but it uses extension methods which I have no idea what it is and how I could implement it. so can anyone help me get this piece of code working ? I need to know what are extension methods and how I could implement them.
thanks