


























此集合基于 NameObjectCollectionBase 类。但与 NameObjectCollectionBase 不同,该类在一个键下存储多个字符串值。
该类可用于标头、查询字符串和窗体数据。
using System;
namespace ConsoleApplication5
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
System.Collections.Specialized.NameValueCollection c = new System.Collections.Specialized.NameValueCollection();
c.Add("a","a");
c.Add("1","3");
c.Add("z","z");
c.Add("1","1");
c.Add("d","d");
for (int i=0; i<c.Count; i++)
{
foreach (string str in c.GetValues(i))
{
Console.WriteLine(str);
}
}
Console.ReadLine();
}
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。