Compact a comma delimited number list into ranges
You could calculate a value to group on, i.e. number - index. All consecutive numbers have the same value:

index  number  number - index
-----  ------  --------------
  0       1          1
  1       2          1
  2       3          1
  3       4          1
  4       5          1
  5      12          7
  6      13          7
  7      14          7
  8      19         11


Then you just check how many items there is in each group to determine if it should be a range.

Example:

List&lt;int&gt; numbers = new List&lt;int&gt; { 1, 2, 3, 4, 5, 12, 13, 14, 19 };

List&lt;string&gt; items = numbers
  .Select((n,i) =&gt; new { number = n, group = n - i })
  .GroupBy(n =&gt; n.group)
  .Select(g =&gt;
    g.Count() &gt;= 3 ?
      g.First().number + "-" + g.Last().number
    :
      String.Join(", ", g.Select(x =&gt; x.number))
  )
  .ToList();

Console.WriteLine(String.Join(", ", items));


Output:

1-5, 12-14, 19