1
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user