title: Unexpected String.Compare() result in .NET 5
body: <p>The problem I am trying to solve is to add multiple target frameworks (NET45 before and NETSTANDARD2.0 new) for a common library. The library contains a lot of utility classes to sort strings. I want to find the best way to keep .NET 5.0 applications to have the same sorting results as before. I want to find out what is the best way to proceed.</p>
  <p>Here is an example.</p>
  <p>Comparing <code>.</code> and <code>-</code> will return a different order in .NET Frameworks 4 and .NET 5. This is a breaking change.</p>
  <p>The results  in the two runtimes are:</p>
  <ul>
  <li><p>.NET Frameworks 4.7: <strong>-1</strong>, which means <code>.</code> &lt; <code>_</code> - <a href="https://dotnetfiddle.net/I0yIr6" rel="nofollow noreferrer">https://dotnetfiddle.net/I0yIr6</a></p>
  </li>
  <li><p>.NET 5.0: <strong>1</strong> which means <code>.</code> &gt; <code>_</code>- <a href="https://dotnetfiddle.net/6YQCmA" rel="nofollow noreferrer">https://dotnetfiddle.net/6YQCmA</a></p>
  </li>
  </ul>
  <pre><code>using System;
  using System.Globalization;
                      
  public class Program
  {
      public static void Main()
      {       
          // returns -1 in NET47 but returns 1 in NET5_0
          Console.WriteLine(string.Compare(&quot;.&quot;, &quot;_&quot;, StringComparison.InvariantCulture));
          Console.WriteLine(string.Compare(&quot;.&quot;, &quot;_&quot;, StringComparison.CurrentCulture));       
          var cultureInfo = new CultureInfo(&quot;en-US&quot;, false);
          Console.WriteLine(string.Compare(&quot;.&quot;, &quot;_&quot;, true, cultureInfo));             
      }
  }
  </code></pre>