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 |
| hashtable [feed], associative array [feed], messagebox [feed], C_sharp [feed], .Net [feed] |
| Related Wikipedia Documents |
| Hash table, Visual Basic .NET, C Sharp, Distributed hash table, Associative array, Array, .NET Framework |
| Related Amazon Books |
| C#: View From Amazon UK/View From Amazon USA CLR Via C#: Applied .NET Framework 2.0 Programming: View From Amazon UK/View From Amazon USA Programming ASP.NET 2.0 Core Reference: View From Amazon UK/View From Amazon USA Programming C#: View From Amazon UK/View From Amazon USA Programming Microsoft Visual C# 2005: The Language: View From Amazon UK/View From Amazon USA |
| 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.
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.
but how I can use the associative array in C#?? there is a System that I have to include (using ???) ??
By , at Tuesday, May 22, 2007 8:31:00 PM


