How to create a ListDictionary in C# Last Updated : 27 Feb, 2019 Comments Improve Suggest changes Like Article Like Report ListDictionary() constructor is used to initialize a new empty instance of the ListDictionary class using the default comparer. ListDictionary is a specialized collection. It comes under the System.Collections.Specialized namespace. This type represents a non-generic dictionary type. It is implemented with a linked list. This class is a simple implementation of a dictionary collection (System.Collections.IDictionary) for small lists. Syntax: public ListDictionary (); Example 1: csharp // C# Program to illustrate how // to create a ListDictionary using System; using System.Collections; using System.Collections.Specialized; class Geeks { // Main Method public static void Main(String[] args) { // ld is the ListDictionary object // ListDictionary() is the constructor // used to initializes a new // instance of the ListDictionary class ListDictionary ld = new ListDictionary(); // Count property is used to get the // number of elements in ListDictionary // It will give 0 as no elements // are present currently Console.WriteLine("The number of elements: "+ ld.Count); } } Output: The number of elements: 0 Example 2: csharp // C# Program to illustrate how // to create a ListDictionary using System; using System.Collections; using System.Collections.Specialized; class Geeks { // Main Method public static void Main(String[] args) { // ld is the ListDictionary object // ListDictionary() is the constructor // used to initializes a new // instance of the ListDictionary class ListDictionary ld = new ListDictionary(); Console.Write("Before Add Method: "); // Count property is used to get the // number of elements in ListDictionary // It will give 0 as no elements // are present currently Console.WriteLine(ld.Count); // Adding key/value pairs in ld ld.Add("Australia", "Canberra"); ld.Add("Belgium", "Brussels"); ld.Add("Netherlands", "Amsterdam"); ld.Add("China", "Beijing"); ld.Add("Russia", "Moscow"); ld.Add("India", "New Delhi"); Console.Write("After Add Method: "); // Count property is used to get the // number of elements in ld Console.WriteLine(ld.Count); } } Output: Before Add Method: 0 After Add Method: 6 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.listdictionary.-ctor?view=netframework-4.7.2#System_Collections_Specialized_ListDictionary__ctor Comment More infoAdvertise with us Next Article How to create a ListDictionary in C# K Kirti_Mangal Follow Improve Article Tags : C# CSharp-Specialized-Namespace CSharp-Specialized-ListDictionary Similar Reads How to create a StringDictionary in C# StringDictionary() constructor is used to initialize a new instance of the StringDictionary class which will be empty and will have the default initial capacity. StringDictionary is a specialized collection. This class comes under the System.Collections.Specialized namespace. It only allows string k 2 min read How to create an OrderedDictionary in C# OrderedDictionary() constructor is used to initialize a new instance of the OrderedDictionary class which will be empty and will have the default initial capacity. OrderedDictionary Class represents a collection of key/value pairs that are accessible by the key or index. It is present in System.Coll 2 min read How to create a StringCollection in C# StringCollection() constructor is used to initializing a new instance of the StringCollection class. StringCollection class is a new addition to the .NET Framework class library that represents a collection of strings. StringCollection class is defined in the System.Collections.Specialized namespace 2 min read C# | How to create a SortedList SortedList class is a collection of (key, value) pairs which are sorted according to keys. Those pairs can be accessible by key and as well as by index(zero-based indexing). This comes under System.Collections namespace. Properties of SortedList: Internally the object of SortedList maintains two arr 2 min read C# | Check if ListDictionary has a fixed size ListDictionary.IsFixedSize property is used to get a value indicating whether the ListDictionary has a fixed size or not. Syntax: public bool IsFixedSize { get; } Return Value : This property always returns false. Example: CSHARP // C# code to check if ListDictionary // has a fixed size using System 1 min read Like