|
How to use SortedDictionary, SortedList, and SortedSet in C#
Take advantage of the SortedDictionary, SortedList, and SortedSet classes in C# to store key-value pairs and sort them based on keys. Thinkstock
SortedDictionary, SortedList, and SortedSet are collection classes that store key-value pairs and can be sorted based on the keys. A SortedSet is a collection that is maintained in sorted order. A SortedList is a collection that lets you retrieve the keys and/or values using indexes. A SortedDictionary lacks indexes but offers faster insertion and removal of unsorted data than a SortedList.
This article talks about SortedDictionary, SortedList, and SortedSet, how they differ, and how we can work with them in C#. To work with the code examples provided in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here.
How to avoid GC pressure in C# and NET infoworld.com - get the latest breaking news, showbiz & celebrity photos, sport news & rumours, viral videos and top stories from infoworld.com Daily Mail and Mail on Sunday newspapers.
Take advantage of read-only generic interfaces such as IReadOnlyList, IReadOnlyDictionary, and IReadOnlyCollection to prevent modifications to collections in your .NET Core applications.
How to work with static anonymous functions in C# 9 infoworld.com - get the latest breaking news, showbiz & celebrity photos, sport news & rumours, viral videos and top stories from infoworld.com Daily Mail and Mail on Sunday newspapers.