IDictionary - ToHashtable
An IDictionary extension method that converts the @this to a hashtable.
public static void Main() { var input = new Dictionary<string, string> {{"txt", "notepad.exe"}, {"bmp", "paint.exe"}, {"dib", "paint.exe"}, {"rtf", "wordpad.exe"}}; // C# Extension Method: IDictionary - ToHashtable Hashtable result = input.ToHashtable(); // return Hashtable; foreach (DictionaryEntry item in result) { Console.WriteLine("[{0}, {1}]", item.Key, item.Value); } }
View Source
using System.Collections; public static partial class Extensions { /// <summary> /// An IDictionary extension method that converts the @this to a hashtable. /// </summary> /// <param name="this">The @this to act on.</param> /// <returns>@this as a Hashtable.</returns> public static Hashtable ToHashtable(this IDictionary @this) { return new Hashtable(@this); } }