A Dictionary object in C# has become one of my recent favorites. Below are a few important aspects:
- Requires including
System.Collections.Generic;
- Each entry in a Dictionary is a KeyValuePair (consisting of two objects: key and value)
- The key must be unique
- The value does not need to be unique
- Both the key and value can be any object (string, int, custom class, etc…)
- Retrieving a value via a key take close to O(1) time
- The order of a KeyValuePair enumeration is not defined
No comments:
Post a Comment