Hi @打玻璃,
I suggest you using dynamic
instead of object[]
. Here is a whole working demo you could follow:
public string BuildParameter(dynamic para)
{
var parameters = "";
IDictionary<string, object> propertyValues = (IDictionary<string, object>)para;
foreach(var item in propertyValues)
{
if(item.Value!=null)
{
parameters+= "&" + item.Key + "=" + item.Value;
}
}
return parameters;
}
You can call this function like:
dynamic s = new ExpandoObject();
s.PageIndex = 1;
s.Filter = "aa";
string parameter = BuildParameter(s);
If there has any problem, please let me know freely.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
Rena