I need to convert a collection of <string,string> to a single string containing all the values in the collection like KeyValueKeyValue… But How do I do this effectively?
I have done it this way at the moment:
parameters = string.Join("", requestParameters.Select(x => string.Concat(x.Key, x.Value)));
But not sure it is the best way to do it, would a string builder be better? I guess the collection will contain a max of 10 pairs.
With such a small collection, there isn’t much of a performance concern, but I would probably just use a StringBuilder to Append all of the values.
Like this: