Add property to anonymous type after creation
问题 I use an anonymous object to pass my Html Attributes to some helper methods. If the consumer didn't add an ID attribute, I want to add it in my helper method. How can I add an attribute to this anonymous object? 回答1: If you're trying to extend this method: public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues); Although I'm sure Khaja's Object extensions would work, you might get better performance by creating a