This commit is contained in:
CortexCore
2023-09-01 14:35:05 +08:00
parent a71288cf2d
commit 5561f5c3cc
136 changed files with 69284 additions and 66121 deletions

View File

@@ -108,16 +108,19 @@ namespace BITKit
return true;
}
}
public static bool TryGet<T>(this IEnumerable<T> self, int index, out T value)
public static bool TryGetElementAt<T>(this IEnumerable<T> self, int index, out T value)
{
if (self.Count() > index)
var enumerable = self as T[] ?? self.ToArray();
if (index >= 0 && enumerable.Count() > index)
{
value = self.ElementAt(index);
value = enumerable.ElementAt(index);
return true;
}
value = default;
return default;
}
[Obsolete("Use TryGetElementAt instead")]
public static bool TryGet<T>(this IEnumerable<T> self, int index, out T value)=>TryGetElementAt(self, index, out value);
public static bool TryInsert<TKey, TValue>(this IDictionary<TKey, TValue> self, TKey key, TValue value)
{