title: Creating a String from a Collection of Objects
body: <p>I have a question. I have a class of <code>Cars</code> that I need to display in a simpli-ish string if they will be sold or not base on their number.</p>
  
  <p>So like this:</p>
  
  <pre><code>Public Class Car
      Property Index As Integer
      Property Sell As Boolean
  End Class
  Public Class Cars
      Property Vehicles As New List(Of Car) From {
                      {New Car With {.Index = 1, .Sell = True}},
                      {New Car With {.Index = 2, .Sell = False}},
                      {New Car With {.Index = 3, .Sell = True}},
                      {New Car With {.Index = 4, .Sell = True}},
                      {New Car With {.Index = 5, .Sell = True}},
                      {New Car With {.Index = 6, .Sell = False}},
                      {New Car With {.Index = 7, .Sell = True}},
                      {New Car With {.Index = 8, .Sell = True}},
                      {New Car With {.Index = 9, .Sell = False}},
                      {New Car With {.Index = 10, .Sell = False}},
                      {New Car With {.Index = 11, .Sell = True}}}
  End Class
  </code></pre>
  
  <p>I'd like to display a simple string like this:
  <strong>Cars to be sold: 1, 3-5, 7-8, 11</strong>, which is based of the <code>.Sell</code> value.</p>
  
  <p>Is there some kind of heuristic to create this kind of string in .NET or is it just a bunch of for/each and if/then and redimming of arrays?</p>