Skip to content

Instantly share code, notes, and snippets.

@davidvesely
Created January 18, 2016 02:36
Show Gist options
  • Select an option

  • Save davidvesely/50f6074b38ee08fdc314 to your computer and use it in GitHub Desktop.

Select an option

Save davidvesely/50f6074b38ee08fdc314 to your computer and use it in GitHub Desktop.
Serializing dictionary to string
public static string DictionaryToString(Dictionary<string, string> d)
{
// Build up each line one-by-one and then trim the end
StringBuilder builder = new StringBuilder();
foreach (KeyValuePair<string, string> pair in d)
{
builder.Append(pair.Key).Append(":").Append(pair.Value).Append(",\n");
}
string result = builder.ToString();
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment