Reputation: 16764
I use this ActionLink method in order to generate method.
LinkExtensions.ActionLink Method (HtmlHelper, String, String, Object)
Sot the 4th parameter is an Object which contains anonymous properties, used for routes.
It is possible to append/add automatically new anonymous properties to existing routeValues which is Object ?
If yes, how ?
Let's assume that I have a method:
public void Test( ref object currentRouteValues, string newValue)
{
if(!string.IsNullOrEmpty(newValue)){
// add a custom property here to currentRouteValues
// something like: (is wrong but I don't know how to proceed)
currentRouteValues = new { currentRouteValues, myCustoProperty = newValue };
}
}
How to do that automatically for above method ?
Thanks
Upvotes: 0
Views: 724
Reputation: 1018
I think this would answer your question.
If you simply want to extract the data it would be something like this.
Object o = new { var1 = "the first var", var2 = "the second var" };
System.Type type = o.GetType();
foreach (var i in type.GetProperties())
{
Console.Write(i.GetValue(o));
}
But for merging, look at the link above.
Upvotes: 1