lundi 16 janvier 2017

Build Query string from many method parameters

I would like to efficiently build a query string which will be used for a REST API call using the method parameters I am receiving (I will likely refactor these to a class, but similar problem still stands). I could use myObject.GetType().GetProperties() and then loop through these, check values for nulls and append. I could also have a dozen of hardcoded if-statements that check each param value and append, but this seems laborious. Which is the recommended way? Anybody done something like this before?





Aucun commentaire:

Enregistrer un commentaire