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

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

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

Definition at line 4141 of file Enumerable.cs.

4142 {
4143 if (source == null)
4144 {
4145 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source);
4146 }
4147 if (selector == null)
4148 {
4149 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.selector);
4150 }
4152 {
4153 while (enumerator.MoveNext())
4154 {
4155 float? num = selector(enumerator.Current);
4156 if (!num.HasValue)
4157 {
4158 continue;
4159 }
4160 double num2 = num.GetValueOrDefault();
4161 long num3 = 1L;
4162 while (enumerator.MoveNext())
4163 {
4164 num = selector(enumerator.Current);
4165 if (num.HasValue)
4166 {
4167 num2 += (double)num.GetValueOrDefault();
4168 num3 = checked(num3 + 1);
4169 }
4170 }
4171 return (float)(num2 / (double)num3);
4172 }
4173 }
4174 return null;
4175 }

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