I have the following enum extension method:
public static IList<SelectListItem> SelectListFor<T>()
{
Type enumType = typeof(T);
if (enumType.IsEnum)
{
return Enum.GetValues(enumType)
.Cast<int>()
.Where(i => !i.Equals(0))
.Select(e => new SelectListItem()
{
Value = e.ToString(),
Text = GetDisplayName(enumType, Enum.GetName(enumType, e))
})
.ToList();
}
return null;
}
I can call this by doing
EnumExtensions.SelectListFor<BrochureTypes>()
And it will allow me to create a drop down list for the values in my BrochureTypes
enum
However, when I compile the code, I get the following warning:
CA1004 Consider a design where 'EnumExtensions.SelectListFor()' doesn't require explicit type parameter 'T' in any call to it.
Can I somehow change the above code to overcome this warning? Or should I just suppress the warning?