DotNet Programming World

Thursday, November 10, 2011

Convert NameValueCollection to Dictionary


public static class NameValueCollectionHelper
{
public static IDictionary ToDictionary
(this NameValueCollection source)
{
return source.Cast()
.Select(s => new { Key = s, Value = source[s] })
.ToDictionary(p => p.Key, p => p.Value); }
}

2 Comments:

  • Hi, Do you have this code in VB.net?

    By Blogger 7N7, at 7:23 AM  

  • This comment has been removed by the author.

    By Blogger 7N7, at 7:24 AM  

Post a Comment

<< Home