I have a question. I have a class of Cars
that I need to display in a simpli-ish string if they will be sold or not base on their number.
So like this:
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
I'd like to display a simple string like this:
Cars to be sold: 1, 3-5, 7-8, 11, which is based of the .Sell
value.
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?