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

◆ Average< TSource >() [8/10]

static ? double System.Linq.Enumerable.Average< TSource > ( this IEnumerable< TSource > source,
Func< TSource, int?> selector )
inlinestatic

Definition at line 4010 of file Enumerable.cs.

4011 {
4012 if (source == null)
4013 {
4014 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source);
4015 }
4016 if (selector == null)
4017 {
4018 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.selector);
4019 }
4020 checked
4021 {
4023 {
4024 while (enumerator.MoveNext())
4025 {
4026 int? num = selector(enumerator.Current);
4027 if (!num.HasValue)
4028 {
4029 continue;
4030 }
4031 long num2 = num.GetValueOrDefault();
4032 long num3 = 1L;
4033 while (enumerator.MoveNext())
4034 {
4035 num = selector(enumerator.Current);
4036 if (num.HasValue)
4037 {
4038 num2 += num.GetValueOrDefault();
4039 num3++;
4040 }
4041 }
4042 return (double)num2 / (double)num3;
4043 }
4044 }
4045 return null;
4046 }
4047 }

References System.Collections.Generic.Dictionary< TKey, TValue >.GetEnumerator(), System.L, System.Linq.selector, System.Linq.source, and System.Linq.ThrowHelper.ThrowArgumentNullException().