Home >Backend Development >C#.Net Tutorial >How to use NameValueCollection class in C#?
NameValueCollection Sets multiple values for a single key. Now let's see how to use them in a C# program.
Set up the collection -
static NameValueCollection GetCollection() { NameValueCollection myCollection = new NameValueCollection(); myCollection.Add("Tim", "One"); myCollection.Add("John", "Two"); myCollection.Add("Jamie", "Three"); return myCollection; }
Now use the GetCollection() method and use the "AllKeys" method attribute to display all keys -
NameValueCollection myCollection = GetCollection(); foreach (string key in myCollection.AllKeys) { Console.WriteLine(key); }
The above is the detailed content of How to use NameValueCollection class in C#?. For more information, please follow other related articles on the PHP Chinese website!