In the asp.net helper, I pass the htmlAttributes variable of the form:
new { @class = "btn btn-default", title = "classic view" }; At the same time inside the helper, I sometimes need to add the css class active when a certain condition is met:
new { @class = "btn btn-default active", title = "classic view" }; How to do it the easiest?
I myself tried to climb through reflection
foreach (var i in htmlAttributes.GetType().GetProperties()) { Console.Write(i.GetValue(a)); } , but remembered that anonymous types are read-only, they are created without any setters .
Is it possible to create a copy with slightly different values?