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: 
The answer of @jrummell in VB.NET for the few of us...

```
Module ModuleExtension

    <Extension()>
    Public Function DisplayName(ByVal value As System.Enum) As String

        Dim enumType As Type = value.GetType()
        Dim enumValue = System.Enum.GetName(enumType, value)
        Dim member As MemberInfo = enumType.GetMember(enumValue)(0)

        Dim attrs = member.GetCustomAttributes(GetType(DisplayAttribute), False)
        Dim outString = CType(attrs(0), DisplayAttribute).Name

        If (CType(attrs(0), DisplayAttribute).ResourceType IsNot Nothing) Then
            outString = CType(attrs(0), DisplayAttribute).GetName()
        End If

        Return outString
    End Function

End Module

```
Here is an extension method that I've written to do just this... it has a little extra logic in it to parse Enum names and split by capital letters. You can override any name by using the Display Attribute

```
public static TAttribute GetAttribute<TAttribute>(this ICustomAttributeProvider parameterInfo) where TAttribute : Attribute
{
    object[] attributes = parameterInfo.GetCustomAttributes(typeof(TAttribute), false);
    return attributes.Length > 0 ? (TAttribute)attributes[0] : null;
}
public static bool HasAttribute<TAttribute>(this ICustomAttributeProvider parameterInfo) where TAttribute : Attribute
{
    object[] attributes = parameterInfo.GetCustomAttributes(typeof(TAttribute), false);
    return attributes.Length > 0 ? true : false;
}

public static string ToFriendlyEnum(this Enum type)
{
    return type.GetType().HasAttribute<DescriptionAttribute>() ? type.GetType().GetAttribute<DescriptionAttribute>().Description : type.ToString().ToFriendlyEnum();
}

public static string ToFriendlyEnum(this string value)
{
    char[] chars = value.ToCharArray();
    string output = string.Empty;

    for (int i = 0; i < chars.Length; i++)
    {
        if (i <= 0 || chars[i - 1].ToString() != chars[i - 1].ToString().ToUpper() && chars[i].ToString() != chars[i].ToString().ToLower())
        {
            output += " ";
        }

        output += chars[i];
    }

    return output.Trim();
}

```

The GetAttribute extension methods could be slightly overkill, but I use them elsewhere in my projects, so they got reused when I wrote my Enum extension. You could easily combine them back into the ToFriendlyEnum(this Enum type) method