Return.cs 786 B

12345678910111213141516171819202122
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Collections.Generic;
  5. namespace System.Linq
  6. {
  7. public static partial class EnumerableEx
  8. {
  9. /// <summary>
  10. /// Returns a sequence with a single element.
  11. /// </summary>
  12. /// <typeparam name="TResult">Result sequence element type.</typeparam>
  13. /// <param name="value">Single element of the resulting sequence.</param>
  14. /// <returns>Sequence with a single element.</returns>
  15. public static IEnumerable<TResult> Return<TResult>(TResult value)
  16. {
  17. yield return value;
  18. }
  19. }
  20. }