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