HttpUtility.ParseQueryString and NameValueCollection in Wind

本文关键字:in Wind NameValueCollection and ParseQueryString HttpUtility | 更新日期: 2023-09-27 18:04:32

我在windows 8应用程序中使用httutility . parsequerystring (string)有一些麻烦我只使用这一行

NameValueCollection coll = HttpUtility.ParseQueryString(result);

问题是,部分"NameValueCollection"answers"HttpUtility"是红色下划线,好像Visual Studio找不到他们(这就是错误说)但是我不知道应该使用哪个命名空间!

我试着

using System.Collections.Specialized ; //for NamevalueCollection
using System.Web ; //for HttpUtility

对于第一个,它似乎不起作用,因为导入是成功的,但我的"NameValueCollection"仍然下划线,对于第二个,VS认为它是一个错误,我的"using"下划线…由于

HttpUtility.ParseQueryString and NameValueCollection in Wind

让它工作:

using System.Collections.Specialized;
using System.Web;
namespace Test   
{
    class Foo
    {
        public Foo()
        {
            NameValueCollection foo = HttpUtility.ParseQueryString("data");
        }
    }
} 

确保引用System.Web.dllSystem.dll

:

http://msdn.microsoft.com/en-us/library/system.collections.specialized.namevaluecollection%28v=vs.110%29.aspx

http://msdn.microsoft.com/en-us/library/ms150046%28v=vs.110%29.aspx

因为OP的问题是关于windows phone的(它没有System.Web),所以在这里可以找到一个替代方案:

HttpUtility。Windows Phone 8中的ParseQueryString和NameValueCollection