Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryGetSingle< TSource >() [2/2]

static TSource System.Linq.Enumerable.TryGetSingle< TSource > ( this IEnumerable< TSource > source,
out bool found )
inlinestaticprivate

Definition at line 7563 of file Enumerable.cs.

7564 {
7565 if (source == null)
7566 {
7567 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source);
7568 }
7570 {
7571 switch (count)
7572 {
7573 case 0:
7574 found = false;
7575 return default(TSource);
7576 case 1:
7577 found = true;
7578 return list[0];
7579 }
7580 }
7581 else
7582 {
7583 using IEnumerator<TSource> enumerator = source.GetEnumerator();
7584 if (!enumerator.MoveNext())
7585 {
7586 found = false;
7587 return default(TSource);
7588 }
7589 TSource current = enumerator.Current;
7590 if (!enumerator.MoveNext())
7591 {
7592 found = true;
7593 return current;
7594 }
7595 }
7596 found = false;
7597 ThrowHelper.ThrowMoreThanOneElementException();
7598 return default(TSource);
7599 }

References System.Linq.count, System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), System.list, System.Linq.source, System.Linq.ThrowHelper.ThrowArgumentNullException(), and System.Linq.ThrowHelper.ThrowMoreThanOneElementException().