I have a strange doubt regarding list and dictionary in c#
In a list we add items to list by using the following method
using System.Collections.Gen
List<>
and Dictionary<,>
- pretty different data structures which used for different purposes, List is simply a set of items and Dictionary is a set of key-value pairs.
Dictionary is pretty useful when you have a set of complex objects and want to have fast access by let's say ObjectName/ObjectId, in this case you create IDictionary
where key would be ObjectId and Value would be an object itself.
Some differences:
O(1)
time complexity to access an item (value) by a key