如何在C#中使用NameValueCollection类?
NameValueCollection为单个键设置多个值。现在让我们看看如何在我们的C#程序中使用它们。
设置集合-
static NameValueCollection GetCollection() {
NameValueCollection myCollection = new NameValueCollection();
myCollection.Add("Tim", "One");
myCollection.Add("John", "Two");
myCollection.Add("Jamie", "Three");
return myCollection;
}现在通过GetCollection()方法,使用“AllKeys”方法属性来显示所有键-
NameValueCollection myCollection = GetCollection();
foreach (string key in myCollection.AllKeys) {
Console.WriteLine(key);
}热门推荐
1 如何训练狗狗握手
10 新员工寄语祝福语简短
11 新婚敬酒祝福语大全简短
12 怎么训练狗狗
13 训练狗狗上厕所
14 春蚕老师祝福语简短励志
15 高考好运如愿祝福语简短
16 战哥过年祝福语简短
17 中考感谢朋友祝福语简短
18 长沙旅游祝福语大全简短