Similar to this question:
Best way to convert a <string, string> dictionary into a single-line String representation?
But I want to ignore the types in the dictionary, since I plan to call the ToString () method for each key and value.
I think this should not be a problem, but I canโt figure out how to go into an untyped dictionary without considering it just as an Object ... any ideas?
[EDIT] Add working code snippet: It works - thanks twoflower
public string DumpDictionary<TKey, TElement>(IDictionary<TKey, TElement> dictionary) { StringBuilder sb = new StringBuilder(); foreach (var v in dictionary) { sb.AppendLine(v.Key.ToString() + ":" + v.Value.ToString()); } return sb.ToString(); }
Aerik source share