How to use NameValueCollection class in C#?

WBOY
Release: 2023-09-18 08:33:07
forward
1437 people have browsed it

如何在 C# 中使用 NameValueCollection 类?

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;
}
Copy after login

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);
}
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!