SoftCircuits.OrderedDictionary 2.1.0

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
.NET 5.0 .NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package SoftCircuits.OrderedDictionary --version 2.1.0
NuGet\Install-Package SoftCircuits.OrderedDictionary -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SoftCircuits.OrderedDictionary" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SoftCircuits.OrderedDictionary --version 2.1.0
#r "nuget: SoftCircuits.OrderedDictionary, 2.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SoftCircuits.OrderedDictionary as a Cake Addin
#addin nuget:?package=SoftCircuits.OrderedDictionary&version=2.1.0

// Install SoftCircuits.OrderedDictionary as a Cake Tool
#tool nuget:?package=SoftCircuits.OrderedDictionary&version=2.1.0


NuGet version (SoftCircuits.OrderedDictionary)

Install-Package SoftCircuits.OrderedDictionary


OrderedDictionary is a .NET library that implements an ordered dictionary. It provides all the functionality of Dictionary<TKey, TValue> but also maintains the items in an ordered list. Items can be added, removed and accessed by key or index. The class implements the IDictionary interface.


OrderedDictionary can be initialized used like any other dictionary. This includes initializing with index initializers.

OrderedDictionary<int, string> dictionary = new OrderedDictionary<int, string>
    [101] = "Bob Smith",
    [127] = "Gary Wilson",
    [134] = "Ann Carpenter",
    [187] = "Bill Jackson",
    [214] = "Cheryl Hansen",

Like a dictionary, items can by accessed by key. They can also be accessed using a 0-based index. Because it's possible for the key to be of type int, the ByIndex property is used to access an item using an index. This prevents any ambiguity between key and index values.

Assert.AreEqual("Gary Wilson", dictionary[127]);
Assert.AreEqual("Bill Jackson", dictionary.ByIndex[3]);

You can add items using the Add() method, and you can also insert them at a particular location.

OrderedDictionary<int, string> dictionary = new OrderedDictionary<int, string>();

dictionary.Add(101, "Bob Smith");
dictionary.Add(127, "Gary Wilson");
dictionary.Add(187, "Bill Jackson");
dictionary.Add(214, "Cheryl Hansen");

dictionary.Insert(2, 134, "Add Carpenter");

Assert.AreEqual("Bob Smith", dictionary[101]);
Assert.AreEqual("Bob Smith", dictionary.ByIndex[0]);
Assert.AreEqual("Gary Wilson", dictionary[127]);
Assert.AreEqual("Gary Wilson", dictionary.ByIndex[1]);
Assert.AreEqual("Add Carpenter", dictionary[134]);
Assert.AreEqual("Add Carpenter", dictionary.ByIndex[2]);
Assert.AreEqual("Bill Jackson", dictionary[187]);
Assert.AreEqual("Bill Jackson", dictionary.ByIndex[3]);
Assert.AreEqual("Cheryl Hansen", dictionary[214]);
Assert.AreEqual("Cheryl Hansen", dictionary.ByIndex[4]);

Items can also be removed using either the key or index.

OrderedDictionary<int, string> dictionary = new OrderedDictionary<int, string>
    [101] = "Bob Smith",
    [127] = "Gary Wilson",
    [134] = "Ann Carpenter",
    [187] = "Bill Jackson",
    [214] = "Cheryl Hansen",

dictionary.RemoveAt(2); // Removes 187 - Bill Jackson

Assert.AreEqual(5 - 2, dictionary.Count);

The library also implements several versions of the ToOrderedList() extension method, which will convert any IEnumerable<> to an OrderedDictionary<>.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 341 12/11/2022
2.1.0 3,097 12/7/2021
2.0.0 351 2/23/2021
1.0.2 386 3/9/2020
1.0.1 333 3/7/2020
1.0.0 429 3/6/2020

Added .NET 6.0 target; Can now retrieve ordered keys; Miscellaneous enhancements.