Created
August 12, 2014 12:30
-
-
Save Cheesebaron/7abd5106a10c464a10e9 to your computer and use it in GitHub Desktop.
Just a simple LINQ query to split an URL's query into a key/value dictionary. Useful in PCL's where there is not HttpUtility class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Dictionary<string, string> QueryToKeyValueDictionary(string url) | |
{ | |
return | |
url.Substring(url.IndexOf('?') + 1) | |
.Split('&') | |
.Select(pair => pair.Split('=')) | |
.ToDictionary(val => val[0], val => Uri.UnescapeDataString(val[1])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment