Skip to content

Instantly share code, notes, and snippets.

@KevM
Created January 6, 2012 19:05
Show Gist options
  • Select an option

  • Save KevM/1571947 to your computer and use it in GitHub Desktop.

Select an option

Save KevM/1571947 to your computer and use it in GitHub Desktop.
Pretty printing a silly collection? Seems like there should be a simpler way.
public static class NameValueCollectionExtensions
{
public static string PrettyPrint(this NameValueCollection collection)
{
var keys = collection.AllKeys.Select(k => "{0} : {1}".ToFormat(k, collection[k]));
return String.Join(Environment.NewLine, keys);
}
}
@tpennetta

Copy link
Copy Markdown

Hi KevM,

I can't seem to track down the "ToFormat" method for the string object. Can you describe the namespace which encapsulates this method?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment