如何在 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);
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP