NameValueCollection cho phép nhiều giá trị cho một khóa. Cách dùng:
Thiết lập collection:
static NameValueCollection GetCollection() {
NameValueCollection myCollection = new NameValueCollection();
myCollection.Add("Tim", "One");
myCollection.Add("John", "Two");
myCollection.Add("Jamie", "Three");
return myCollection;
}
Dùng AllKeys để hiển thị tất cả khóa:
NameValueCollection myCollection = GetCollection();
foreach (string key in myCollection.AllKeys) {
Console.WriteLine(key);
}