Re: Ordered Name/Value pair

Dean Cleaver <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.cx
Message-ID <7E50DCC922CBA24B888112067DFAB8A153F3B8@sxslakl001.xceptionsoftware.com>
Thanx everyone.

I've used this NameValue collection - I looked in the help files under
Collections, and never once thought to look in Specialized - I'll blame
it on the flu. Not looking to use generics as it's only for passing name
value pairs through an interface, and don't want to go as far as
creating a class to contain them etc - NameValue collection serves the
purpose nicely.

Thanx for the help.

Cheers,
Dino 

-----Original Message-----
From: Discussion relating to the specifics of the C# and Managed C++
languages [mailto:[email protected]] On Behalf Of Phillip
Holmes
Sent: Wednesday, 26 July 2006 15:01
To: [email protected]
Subject: Re: [DOTNET-CX] Ordered Name/Value pair

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(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
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.