Exemple #1
0
        public static int SumFastEnumerable(ListLike <int> list)
        {
            var sum = 0;
            var e   = list.GetFastEnumerator();
            var x   = e.TryMoveNext(out var success);

            while (success)
            {
                sum += x;
                x    = e.TryMoveNext(out success);
            }
            return(sum);
        }
 [Benchmark] public int SumFastEnumeratorInterface() => Sum.SumFastEnumeratorInterface(_data.GetFastEnumerator());
Exemple #3
0
 [Fact] public void SumFastEnumeratorInterface() => Assert.Equal(_expected, Sum.SumFastEnumeratorInterface(_data.GetFastEnumerator()));