Я делаю расширение.
public static MvcHtmlString Image(this HtmlHelper helper, string src, object htmlAttributes = null)
{
TagBuilder builder = new TagBuilder("img");
builder.MergeAttribute("src", src);
if (htmlAttributes != null) builder.MergeAttributes(htmlAttributes);
return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
}
Эта строка:
if (htmlAttributes != null) builder.MergeAttributes(htmlAttributes);
Ошибки с:
The type arguments for method 'System.Web.Mvc.TagBuilder.MergeAttributes<TKey,TValue>(System.Collections.Generic.IDictionary<TKey,TValue>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Я пробовал:
if (htmlAttributes != null) builder.MergeAttributes((Dictionary<string, string>)htmlAttributes);
и
if (htmlAttributes != null) builder.MergeAttributes((Dictionary<string, object>)htmlAttributes);
Как мне заставить это работать?