System.Collections.IDictionary Extension Methods

IDictionary.ToHashtable Method

An IDictionary extension method that converts the @this to a hashtable.


Hashtable ToHashtable(IDictionary @this)


The @this to act on.


 // Copyright (c) 2013 Jonathan Magnan (
 // All rights reserved.
 // Licensed under MIT License (MIT)
 // License can be found here:
 using System.Collections;
 using System.Collections.Generic;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Z;
 namespace ExtensionMethods.Examples
     public class System_Collections_IDictionary_ToHashtable
         public void ToHashtable()
             // Type
             var @this = new Dictionary<string, string> {{"Fizz", "Buzz"}};
             // Examples
             Hashtable value = @this.ToHashtable(); // return the Dictionary as Hashtable
             // Unit Test
             Assert.AreEqual("Buzz", value["Fizz"]);

Last edited Nov 23, 2013 at 6:52 PM by Jonathan_Magnan, version 1