title: Fast ways to avoid duplicates in a List<> in C#
body: <p>My C# program generates random strings from a given pattern. These strings are stored in a list. As no duplicates are allowed I'm doing it like this:</p>
  
  <pre><code>List&lt;string&gt; myList = new List&lt;string&gt;();
  for (int i = 0; i &lt; total; i++) {
    string random_string = GetRandomString(pattern);
    if (!myList.Contains(random_string)) myList.Add(random_string);
  }
  </code></pre>
  
  <p>As you can imagine this works fine for several hundreds of entries. But I'm facing the situation to generate several million strings. And with each added string checking for duplicates gets slower and slower.</p>
  
  <p>Are there any faster ways to avoid duplicates?</p>