Skip to content

Instantly share code, notes, and snippets.

@dancrowley303
Created August 6, 2010 05:52
Show Gist options
  • Save dancrowley303/510904 to your computer and use it in GitHub Desktop.
Save dancrowley303/510904 to your computer and use it in GitHub Desktop.
namespace Utilities
{
public class QueryStringBuilder : Dictionary<string, string>
{
public string Generate()
{
if (Count == 0) return string.Empty;
return "?" + string.Join("&", GenerateSegments());
}
private IEnumerable<string> GenerateSegments()
{
return Keys.Select(key => key + "=" + this[key]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment