2018年2月1日 星期四
【C# NameValueCollection】 針對NameValueCollection 做 LINQ
public static Dictionary ParseQueryString(string queryString)
{
System.Collections.Specialized.NameValueCollection nvc = System.Web.HttpUtility.ParseQueryString(queryString);
var a = from key in nvc.Cast()
from value in nvc.GetValues(key)
where key != null
select new { key, value };
return a.ToDictionary(pair => pair.key, pair => pair.value); ;
}
{
System.Collections.Specialized.NameValueCollection nvc = System.Web.HttpUtility.ParseQueryString(queryString);
var a = from key in nvc.Cast
from value in nvc.GetValues(key)
where key != null
select new { key, value };
return a.ToDictionary(pair => pair.key, pair => pair.value); ;
}
訂閱:
文章 (Atom)