I need to add the parameters and the values to the following object dynamically. So far, I do it statically (hardcoded) by creating the object as follows:
object parameters = new { Param1 = UserNumber, Param2 = "201403", Param3 = true };
Then in the function, pass it as:
Helper.create(parameters);
^This works.
But, sometimes I just need to pass just one, none, or more than those three. The amount can change dynamically and not necessarily be named the same or it can be in a different order. So, I can't leave the name of the variables Param1, Param2 and Param3 statically. I also, don't control the behavior for the 'create()' function.
I tried this (and more):
List<Tuple<object, object>> tupleList = new List<Tuple<object, object>>();
tupleList.Add(new Tuple<object, object>("Number", UserNumber));
tupleList.Add(new Tuple<object, object>("Start", 201403));
tupleList.Add(new Tuple<object, object>("Show", true));
object tuptest = tupleList.Cast<object>().ToArray();
But it creates it as one array with objects inside. When you go step by step in the debugging, they show up differently than what I need.
The Documentation example is:
Helper.create( new { Parameter1 = "Text", Parameter2 = 1000 } );
How can I create this dynamically?
createexpecting to receive?