diff --git a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs index 71061ed..1321284 100644 --- a/ICD.Common.Utils/Extensions/EnumerableExtensions.cs +++ b/ICD.Common.Utils/Extensions/EnumerableExtensions.cs @@ -174,8 +174,23 @@ namespace ICD.Common.Utils.Extensions { return false; } + } - return false; + /// + /// Gets the element at the given index. Returns the specified default value if the index does not exist. + /// + /// + /// + /// + /// + /// + public static T ElementAtOrDefault(this IEnumerable extends, int index, T defaultValue) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + T output; + return extends.TryElementAt(index, out output) ? output : defaultValue; } ///