What's the most efficient way to convert a Dictionary to a formatted string.
e.g.:
My method:
public string DictToString(Dictionary<string, string> items, string format){
format = String.IsNullOrEmpty(format) ? "{0}='{1}' " : format;
string itemString = "";
foreach(var item in items){
itemString = itemString + String.Format(format,item.Key,item.Value);
}
return itemString;
}
Is there a better/more concise/more efficient way?
Note: the Dictionary will have at most 10 items and I'm not committed to using it if another similar "key-value pair" object type exists
Also, since I'm returning strings anyhow, what would a generic version look like?