title: Formatting a string using values from a generic list by LINQ
body: <p><strong>Question Updated</strong></p>
  
  <p>I have a generic list which can contains the following values:</p>
  
  <pre><code>Sector 1
  Sector 2
  Sector 4
  </code></pre>
  
  <p>or the following value:</p>
  
  <pre><code>All Sectors
  </code></pre>
  
  <p>I want to format this values in a string like this:</p>
  
  <pre><code>Sector 1 &amp; 2 &amp; 4 - 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>All Sectors -
  </code></pre>
  
  <p>Currently, I have the following code to format the same. It works, but is very complicated.</p>
  
  <pre><code>string retrieveSectors += sectors.Count == 0
                                 ? string.Empty
                                 : sectors.OrderBy(
                                 y =&gt;
                                 y.Sector.Substring(
                                 y.Sector.Length - 1, 1)).
                                 GroupBy(g =&gt; g.Sector).Select(
                                 g =&gt; g.First()).ToList().Aggregate(
                                 retrieveSectors,
                                 (current, y) =&gt;
                                 (current == retrieveSectors
                                 ? current +
                                 y.Sector
                                 : current + " &amp; " +
                                 y.Sector.
                                 Substring(
                                 y.Sector.
                                 Length - 1, 1))) + " - "
  </code></pre>
  
  <p>In the above code, the variable sector is the generic list. Can someone help me to attain the results in a simplified way.? Or may be modify the above code so that it is more understandable.</p>
  
  <p>Any help appreciated. Thanks</p>