I have the following method:
public static string UlList(this HtmlHelper helper, List<IEntity> entities, string css)
{
return "foo";
}
However when i try and call the method
<%= Html.UlList(Model.ProfileRequiredFields, css)%>
I get:
Compiler Error Message: CS1928: ‘System.Web.Mvc.HtmlHelper’ does not contain a definition for ‘UlList’ and the best extension method overload ‘System.Web.Mvc.HtmlHelpers.UlList(System.Web.Mvc.HtmlHelper, System.Collections.Generic.List, string)’ has some invalid arguments
Model.RequiredFields = new List<ProfileRequiredField>();
public class ProfileRequiredField : IEntity
{
public int Id { get; set; }
public string Name { get; set; }
}
EDIT
I’m using 3.5
What you’re trying to do, with
List<IEntity>as the parameter type, works only in .NET 4.0 because of the newoutkeyword.If you need this to work in lower versions, try the following:
This replaces
IEntitywith a generic argument. .NET will automatically resolve this for you, so you don’t have to add<ProfileRequiredField>in your code.