Example #1
0
        public void aggregate1_readonly_span()
        {
            ReadOnlySpan <int> values = stackalloc int[] { 1, 1, 2, 4, 8, 16 };

            Assert.Equal(32, values.Aggregate(
                             (a, n) =>
            {
                Assert.Equal(a, n);
                return(a + n);
            }));
        }
Example #2
0
        public void aggregate3_readonly_span()
        {
            ReadOnlySpan <int> values = stackalloc int[] { 1, 2, 4, 8, 16 };

            Assert.Equal(33, values.Aggregate(1,
                                              (a, n) =>
            {
                Assert.Equal(a, n);
                return(a + n);
            },
                                              a => a + 1));
        }