Possible Duplicates:
How can I create a singleton IEnumerable?
Favorite way to create an new IEnumerable<T> sequence from a single value?
Say I need to return an IEnumerable which contains only one element.
I could return a list as in
return new List<Whatever> (myItem);
or an array for that matter.
But it would be preferable to create a Singleton method
public IEnumerable<T> Singleton (T t)
{
yield return t
}
Before I put this everywhere in my code, isn't there a method which already does this?