Re: Ordered Name/Value pair

Phillip Holmes <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <003901c6b05f$b7517b30$0200a8c0@core>
Dino,

Look in System.Collections.Specialized.


            NameValueCollection stFoo = new NameValueCollection();
            stFoo.Add("akey", "value1");
            stFoo.Add("akey", "value2");
            stFoo.Add("akey", "value3");
            stFoo.Add("bkey", "value1");
            stFoo.Add("bkey", "value2");
            stFoo.Add("bkey", "value3");

            string[] a_foo = stFoo.GetValues("akey");
            foreach (string it in a_foo)
            {
                Console.WriteLine(it);
            }

            string[] b_foo = stFoo.GetValues("akey");
            foreach (string it in b_foo)
            {
                Console.WriteLine(it);
            }

Warmest Regards,

Phillip B. Holmes
http://phillipholmes.com
214-995-6175 (cell)





-----Original Message-----
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:[email protected]] On Behalf Of Dean Cleaver
Sent: Tuesday, July 25, 2006 9:13 PM
To: [email protected]
Subject: [DOTNET-CX] Ordered Name/Value pair

I'm having a brain fade here - I need to add a list of keys and objects to a
list in a given order. I tried a hashtable, but it changes the order, and
the sortedlist will obviously sort them by the key which I don't want.

Is there another class that uses Name/Value pairs but doesn't change your
order?

TIA
Dino

--
Internal Virus Database is out-of-date.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: 7/17/2006

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.