You can use any collection that uses hash search because their member search is very fast. e.g. Dictionary <K,V> , OrderedDictionary . There is also a non-structural Hashtable , which basically turns out to be redundant with a generic Dictionary<K,V> . In Big-O notation, the time it takes to search for elements by key elements for these O(1) collections is just as good as it gets.
To access the elements, so as not to take the cost of two searches, instead of using ContainsKey you can use the TryGetValue method, for example:
Dictionary<Guid, Student> students = GetStudents(); Student student; if (students.TryGetValue(guid, out student)) {
BTW, OrderedDictionary also allows you to access elements by index.
source share