title: Does List<String>.Contains(mystring) do a reference comparison or a value comparison?
body: <p>Does List.Contains(mystring) do a reference comparison or a value comparison?
  Eg I have this code:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// If the value isn't null or an empty string, 
  /// and doesn't exist in the list, it adds it to the list
  /// &lt;/summary&gt;
  static void AddToListIfNotEmpty(List&lt;string&gt; thelist, SqlString val)
  {
    string value = val.ToString().Trim();
    if (!string.IsNullOrEmpty(value))
    {
      bool found = false;
      foreach (string x in thelist) if (x == value) found = true;
      if (!found) thelist.Add(value);
    }
  }
  </code></pre>
  
  <p>Can i simplify the foreach and following line to:</p>
  
  <pre><code>if (!thelist.Contains(value)) thelist.Add(value);
  </code></pre>
  
  <p>Thanks</p>