Posted By

ajit555 on 02/05/10


Tagged

url String Linq


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Who likes this?

1 person has marked this snippet as a favorite

mamona


Get URL Parameters using LINQ


Published in: C# 






URL: http://snipplr.com/view/27185/get-url-parameters-using-linq/

Expand | Embed | Plain Text
  1. Dictionary<String, String> result = new Dictionary<string, string>();
  2. String urlString = "http://www.jwize.com?param1=valu1&param2=value2";
  3.  
  4. var query = from match in urlString.Split('?').Where(m => m.Contains('='))
  5. .SelectMany(pr => pr.Split('&'))
  6. where match.Contains('=')
  7. select new KeyValuePair<string, String>(
  8. match.Split('=')[0],
  9. match.Split('=')[1]);
  10. query.ToList().ForEach(kvp => result.Add(kvp.Key, kvp.Value));

Report this snippet 

You need to login to post a comment.

Download royalty free graphics