I have a problem when I need to extract a query string parameter from a url. The parameter can be either "Territory" or "Territory" or other variants of the upper and lower case of this word. Although the following works in the first two cases, I wonder if there is a better way?
IDictionary<string, string> queryString = HtmlPage.Document.QueryString; if (queryString.ContainsKey("territory")) { ish.SetDefaultRegion(int.Parse(queryString["territory"])); // do something (the same something as below) } else if (queryString.ContainsKey("Territory")) { ish.SetDefaultRegion(int.Parse(queryString["Territory"])); // do something (the same something as above) }
I would prefer to insert a query string into a case-insensitive dictionary (ie if the user accidentally typed "Territory" , this code will not work, since I can just check that the word exists regardless of the cover?
rmcsharry
source share