Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ListDictionary Class vs List<Dictionary> C#

I’ve been search a lot about which one is better but I can’t find something like a comparison.
What is the advantage of using the ListDictionary Class instead of using a List of Dictionary’s?

I needed a List of dictionary in my project and i was searching when i found ListDictionary Class, but I can’t find something like a post to know more about which one is better on x or y project (I’m currently working on .NET 4+ and WPF).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

ListDictionary is very specific implementation of dictionary.

From the docs https://learn.microsoft.com/en-us/dotnet/api/system.collections.specialized.listdictionary?view=net-7.0

Implements IDictionary using a singly linked list. Recommended for collections that typically include fewer than 10 items.

It is not a list of dictionaries, it is just a single plain dictionary. And of course it is not an equivalent of the List<Dictionary>, which actually is a list of dictionaries.

Conclusion: if you need many dictionaries placed into the list, then the List<Dictionary> is only option for you. The ListDictionary is totally unusable here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading