Loops vs HashSets

Posted by Joe Enos on January 16, 2021 · 1 min read

When looking up data in memory from a large collection, a HashSet or Dictionary is much, much faster than looping through an ordinary collection.

This example uses strings - if you run the same code but treat them as GUIDs, the numbers improve quite a bit, but the difference between array and HashSet is still tremendous.

View code on GitHub