Pushes the elements of the specified collection to the . The type of elements in the collection. The to add items to. The collection whose elements should be pushed on to the . It can contain elements that are <see langword="
(this Stack<T> stack, IEnumerable<T> collection)
| 127 | /// <param name="collection">The collection whose elements should be pushed on to the <paramref name="stack"/>. It can contain elements that are <see langword="null"/>, if type <typeparamref name="T"/> is a reference type.</param> |
| 128 | /// <exception cref="ArgumentNullException">If <paramref name="stack"/> or <paramref name="collection"/> are <see langword="null"/>.</exception> |
| 129 | public static void PushRange<T>(this Stack<T> stack, IEnumerable<T> collection) |
| 130 | { |
| 131 | if (stack == null) |
| 132 | throw new ArgumentNullException(nameof(stack)); |
| 133 | if (collection == null) |
| 134 | throw new ArgumentNullException(nameof(collection)); |
| 135 | foreach (var item in collection) |
| 136 | { |
| 137 | stack.Push(item); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /// <summary> |
| 142 | /// Performs the specified action on each element of the <see cref="IEnumerable{T}"/>. |