| 123456789101112131415161718192021222324252627282930313233343536 | // Licensed to the .NET Foundation under one or more agreements.// The .NET Foundation licenses this file to you under the Apache 2.0 License.// See the LICENSE file in the project root for more information. using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;namespace System.Linq{    public static partial class EnumerableEx    {        /// <summary>        ///     Returns a sequence that throws an exception upon enumeration.        /// </summary>        /// <typeparam name="TResult">Result sequence element type.</typeparam>        /// <param name="exception">Exception to throw upon enumerating the resulting sequence.</param>        /// <returns>Sequence that throws the specified exception upon enumeration.</returns>        public static IEnumerable<TResult> Throw<TResult>(Exception exception)        {            if (exception == null)                throw new ArgumentNullException(nameof(exception));            return Throw_<TResult>(exception);        }        private static IEnumerable<TResult> Throw_<TResult>(Exception exception)        {            throw exception;#pragma warning disable 0162            yield break;#pragma warning restore 0162        }    }}
 |