1
2
3
4
5
6
7
8
9
10
11
12
13
14
public static class IEnumerableExt
{
/// <summary>
/// Wraps this object instance into an IEnumerable&lt;T&gt;
/// consisting of a single item.
/// </summary>
/// <typeparam name="T"> Type of the object. </typeparam>
/// <param name="item"> The instance that will be wrapped. </param>
/// <returns> An IEnumerable&lt;T&gt; consisting of a single item. </returns>
public static IEnumerable<T> Yield<T>(this T item)
{
yield return item;
}
}
1
2
3
new T[] { item }
// or
new [] { item }
1
2
3
4
public static IEnumerable<T> ToEnumerable<T>(params T[] items)
{
return items;
}