Question: I have the following helper method in a `ViewModelBase` class, which is inherited by other view Models:

```
public string GetEnumName<T>(Enum value)
        {
            Type enumType = typeof(T);
            var enumValue = Enum.GetName(enumType, value);
            MemberInfo member = enumType.GetMember(enumValue)[0];

            var attrs = member.GetCustomAttributes(typeof(DisplayAttribute), false);
            var outString = ((DisplayAttribute)attrs[0]).Name;

            if (((DisplayAttribute)attrs[0]).ResourceType != null)
            {
                outString = ((DisplayAttribute)attrs[0]).GetName();
            }

            return outString;
        }

```

I then call this from the view like this:

```
<p>
@{var rel = Model.GetEnumDisplayName<Enums.wheteverEnum>(Model.wheteverEnum); }
@rel
</p>

```

Question is - can I work this method so I don't have to tell it the type of the `enum`? Basically I'd like todo this for all `enum`s:

 @Model.GetEnumDisplayName(Model.wheteverEnum)

No `typeof`, no `T`, no need to add a reference to the `Enums` namespace in the View...

Possible?

Answer: 
Could you not write this as an extension method? Something like...

```
public static class EnumExtensions
{
  public static string ToDescription(this Enum e)
  {
     var attributes = (DisplayAttribute[])e.GetType().GetField(e.ToString()).GetCustomAttributes(typeof(DisplayAttribute), false);
     return attributes.Length > 0 ? attributes[0].Description : string.Empty;
  }
}

```

Usage:

```
@Model.WhateverEnum.ToDescription();

```
The suggested sollutions does not worked for me with MVC3: so the helper below is good.:

```
    public static string GetEnumDescription(this Enum value)
    {
        Type type = value.GetType();
        string name = Enum.GetName(type, value);
        if (name != null)
        {
            FieldInfo field = type.GetField(name);
            if (field != null)
            {
                string attr = field.GetCustomAttributesData()[0].NamedArguments[0].TypedValue.Value.ToString();
                if (attr == null)
                {
                    return name;
                }
                else
                {
                    return attr;
                }
            }
        }
        return null;
    }

```