title: Why do I get duplicate keys as using groupby LINQ
body: <p>I'm using the following snippet to catch all debts belonging to a customer belonged to an account number which is unique. However, I get duplicates of the account numbers even I have chosen it as the key. I'm too amazed.</p>
  
  <pre><code>var records      = myList;
  var groupedList  = records?
                        .GroupBy(x =&gt; x.AccountNumber.Where(char.IsDigit).ToArray())
                        .Select(e =&gt; new {
                               AccountNumber = new string(e.Key), 
                               TotalDebt = e.Sum(x =&gt; x.TotalDebt)
                              }
                         );
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0SBpN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0SBpN.jpg" alt="q"></a></p>