Concat

static IEnumerable<T> Concat<T>(IEnumerable<T> target, T element)
{
  return System.Linq.Concat(target, new[]{ element };
}

or

static IEnumerable<T> Concat<T>(IEnumerable<T> target, T element)
{
  foreach(T e in target) yield return e;
  yield return element;
}
Example:
IEnumerable<String> x = new[]{"foo", "bar"};
x = x.Concat("bla");
Console.WriteLine(string.Join('--',x));

// returns foo--bar--bla

Description

Adds an element to an IEnumerable (System.Linq.Concat only adds multiple elements)

Details

Double click on the code to select all.

 

;