.Net application development specialists
asp.net, c#, vb.net, html, javascript, jquery, html, xhtml, css, oop, design patterns, sql server, mvc and much more
contact: admin@paxium.co.uk

Paxium is the company owned by myself, Dave Amour and used for providing IT contract development services including


  • Application development - Desktop, Web, Services - with Classic ASP, Asp.net WebForms, Asp.net MVC, Asp.net Core
  • Html, Css, JavaScript, jQuery, React, C#, SQL Server, Ado.net, Entity Framework, NHibernate, TDD, WebApi, GIT, IIS
  • Database schema design, implementation & ETL activities
  • Website design and hosting including email hosting
  • Training - typically one to one sessions
  • Reverse Engineering and documentation of undocumented systems
  • Code Reviews
  • Performance Tuning
  • Located in Cannock, Staffordshire
Rugeley Chess Club Buying Butler Cuckooland Katmaid Pet Sitting Services Roland Garros 60 60 Golf cement Technical Conformity Goofy MaggieBears Vacc Track Find Your Smart Phone eBate Taylors Poultry Services Lafarge Rebates System Codemasters Grid Game eBate DOFF

Collection Classes in .net - the ListDictionary

This is the fourteenth part of an article on collection classes in .net with C#.  This part covers the ListDictionary.

For the first part see http://www.audacs.co.uk/ViewPage.aspx?PageID=512

For the next part on NameValueCollection see http://www.audacs.co.uk/ViewPage.aspx?PageID=527

This class implements IDictionary using a singly linked list. Recommended for collections that typically contain 10 items or less.

I cannot see anything at the interface end which is linked list like so looks like the linked list usage is just under the hood so not sure what the point of that is?

It can be found at System.Collections.Specialized.ListDictionary

It contains key value pairs which are in the form of DictionaryEntry objects and items are retrievable via iteration or via key.

Below is a sample program showing the typical usage of this class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Collections;
 
namespace ListDictionaryExamples
{
    class Program
    {
        static void Main(string[] args)
        {
            ListDictionary drinks = new ListDictionary();
 
            drinks.Add("Lager", 1.98);
            drinks.Add("Guiness", 2.11);
            drinks.Add("Bitter", 2.05);
            drinks.Add("Red Wine", 2.45);
            drinks.Add("White Wine", 2.35);
 
            Console.WriteLine("Output drink contents using foreach");
           
            foreach (DictionaryEntry drink in drinks)
            {
                Console.WriteLine(drink.Key + " " + drink.Value);
            }
 
            Console.WriteLine();
           
            IDictionaryEnumerator drinksEnumerator = drinks.GetEnumerator();
 
            Console.WriteLine("Output drink contents using enumerator");
 
            while (drinksEnumerator.MoveNext())
            {
                Console.WriteLine(drinksEnumerator.Key + " " + drinksEnumerator.Value);
            }
 
            Console.WriteLine();
 
            Console.WriteLine(drinks["Bitter"]);
 
            Console.Read();
        }
    }
}


The output from this program is as follows:

Thats as much as there is to the ListDictionary.

For the next part on NameValueCollection see http://www.audacs.co.uk/ViewPage.aspx?PageID=527