-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCollectionExtensions.cs
More file actions
29 lines (27 loc) · 923 Bytes
/
CollectionExtensions.cs
File metadata and controls
29 lines (27 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Arenas {
internal static class CollectionExtensions {
public static void SetLast<T>(this IList<T> list, T item) {
if (list is null) {
throw new ArgumentNullException(nameof(list));
}
if (list.Count == 0) {
throw new ArgumentOutOfRangeException("List in SetLast was empty");
}
list[list.Count - 1] = item;
}
public static void SetLast<T>(this IList<T> list, ref T item) {
if (list is null) {
throw new ArgumentNullException(nameof(list));
}
if (list.Count == 0) {
throw new ArgumentOutOfRangeException("List in SetLast was empty");
}
list[list.Count - 1] = item;
}
}
}