. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Thursday, April 20, 2006

Associative Array C# .Net

A visitor to my site from google was looking for: associative array c# .net.

The only thing I can say about this really is that an associative array in C# is just a hash table.

The hash table associates a key of type object with an associated object.
For Example:

Hashtable ht = new Hashtable();
ht.Add("testKey", "AssociatedData");
MessageBox.Show(ht["testKey"]);

Related Tags
[feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , , , ,

My Related Documents
, , , , ,

Related Amazon Books
C#: / CLR Via C#: Applied .NET Framework 2.0 Programming: / Programming ASP.NET 2.0 Core Reference: / Programming C#: / Programming Microsoft Visual C# 2005: The Language: /

Related Images From Flickr

Comments: [Add New]

Although the behaviour may look the same, a Hashtable is not the same as an Associative array. The difference is that Associative arrays are sorted, whereas Hashtable are not (I mean, they are, but for a hashcode we don't really care about).

That is, a foreach on a Hashtable doesn't list the elements in the same order you add them, nor can you change the order of a certain element in the table (not that you can on Associative arrays either unless using an indirect way).

BTW, I think you could accept the "code" tag.

By Anonymous Ralph, at Tuesday, August 29, 2006 4:59:00 PM

That person was probably looking for a way to pass an associative array via a Web Service, since Hashtables are not supported.

.NET is nice enough to let us write web services without writing raw SOAP XML, but not nice enough to convert a Hashtable to a SOAP associative array.

I'm passing a string[][] associative array, but apparently that's not the same as a SOAP associative array, according to the person consuming my web service.

So, how do you pass a SOAP associative array? Still trying to figure that one out.

By Anonymous Matt, at Wednesday, November 08, 2006 4:02:00 PM

but how I can use the associative array in C#?? there is a System that I have to include (using ???) ??

By Anonymous domenico, at Tuesday, May 22, 2007 8:31:00 PM

this tip was help me thanx

By Anonymous Anonymous, at Monday, July 14, 2008 1:32:00 PM

Thank you for the tip, This is exactly the information i was looking for :)

By Anonymous Anonymous, at Friday, March 27, 2009 3:51:00 PM