Hast Table - Dictionary Learn programming C#



Lesson:

Dynamic Memory Management


Exercise:

Hast Table - Dictionary


Objetive:

Submit your dictionary here using a hash table.


Code:

using System;
using System.Collections;
namespace TableHash
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable myList = new Hashtable();

            myList.Add("white", "blanco");
            myList.Add("black", "negro");

            Console.WriteLine("The size is: " + myList.Count);

            Console.WriteLine("Contenido:");
            IDictionaryEnumerator miEnumerador = myList.GetEnumerator();

            while (miEnumerador.MoveNext())
                Console.WriteLine("{0} = {1}", miEnumerador.Key, miEnumerador.Value);

            if (myList.ContainsKey("orange"))
            {
                Console.WriteLine(myList["orange"]);
            }
        }
    }
}



Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.