本文整理汇总了C#中QueryString.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# QueryString.RemoveAll方法的具体用法?C# QueryString.RemoveAll怎么用?C# QueryString.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryString
的用法示例。
在下文中一共展示了QueryString.RemoveAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCount
public void TestCount()
{
QueryString qs = new QueryString();
Assert.AreEqual(0, qs.Count());
qs.Add("name", "Andrew");
Assert.AreEqual(1, qs.Count());
qs.Add("age", "22");
Assert.AreEqual(2, qs.Count());
qs.Add("name", "Lei");
Assert.AreEqual(3, qs.Count());
qs.Set("name", "Thomas");
Assert.AreEqual(2, qs.Count());
qs.Add("name", "Matt");
Assert.AreEqual(3, qs.Count());
qs.Remove("name", "Matt");
Assert.AreEqual(2, qs.Count());
qs.Remove("name", "Thomas");
Assert.AreEqual(1, qs.Count());
qs.Remove("age");
Assert.AreEqual(0, qs.Count());
qs.Add("name", "Andrew");
qs.Add("name", "Lei");
Assert.AreEqual(2, qs.Count());
qs.RemoveAll("name");
Assert.AreEqual(0, qs.Count());
}
示例2: TestRemoveAllWithValues
public void TestRemoveAllWithValues()
{
QueryString qs = new QueryString()
{
{ "name", "Andrew" },
{ "age", "22" }
};
Assert.AreEqual(0, qs.RemoveAll("age", "21"));
Assert.AreEqual(0, qs.RemoveAll("age", null));
Assert.AreEqual(1, qs.RemoveAll("age", "22"));
AssertEqual(new QueryString()
{
{ "name", "Andrew" }
}, qs);
Assert.AreEqual(0, qs.RemoveAll("age", "22"));
qs.Add("name", "Lei");
qs.Add("name", "Andrew");
qs.Add("name", "Thomas");
Assert.AreEqual(2, qs.RemoveAll("name", "Andrew"));
AssertEqual(new QueryString()
{
{ "name", "Lei" },
{ "name", "Thomas" }
}, qs);
}
示例3: TestRemoveAll_MultipleKeys
public void TestRemoveAll_MultipleKeys()
{
QueryString qs = new QueryString()
{
{ "name", "Andrew" },
{ "name", "Lei" },
{ "name", "Thomas" },
{ "age", "22" }
};
Assert.IsTrue(qs.RemoveAll("name"));
AssertEqual(new QueryString()
{
{ "age", "22" }
}, qs);
Assert.IsFalse(qs.RemoveAll("name"));
}
示例4: TestRemoveAll_OnlyKey
public void TestRemoveAll_OnlyKey()
{
QueryString qs = new QueryString()
{
{ "name", "Andrew" },
{ "age", "22" }
};
Assert.IsTrue(qs.RemoveAll("age"));
AssertEqual(new QueryString()
{
{ "name", "Andrew" }
}, qs);
Assert.IsFalse(qs.RemoveAll("age"));
}