Articles

Hashtables and .Net Web Services

In .Net on October 21, 2008 by Matt Grande Tagged: , , , ,

If you’ve spent any time with .Net Webservices, you’ve probably seen this error:

System.NotSupportedException: The type System.Collections.Hashtable is not supported because it implements IDictionary.

Recently my co-worker Chelsea and I devised a way to get around this.  Hashtables are essentially collections of DictionaryEntrys with some extras to make certain functions.  So, all you have to do is convert from a Hashtable to a List<DictionaryEntry>.  Here’s how:

private static List<DictionaryEntry> ConvertHashToDictionaryEntryList(Hashtable source)
{
    var resultList = new List<DictionaryEntry>();

    foreach (DictionaryEntry item in source)
        resultList.Add(item);

    return resultList;
}

Hope this helps!  Happy coding.

Advertisements

3 Responses to “Hashtables and .Net Web Services”

  1. this suckz

  2. Thanks for the input. Why do you feel it sucks? Can you suggest a better alternative.

  3. It was awesome it worked for me thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: