Exemplo n.º 1
0
            // Type: decimal, selector function is called
            public static int Test8g()
            {
                Data_Ndecimal[] source = new Data_Ndecimal[] { new Data_Ndecimal {
                                                                   name = "Tim", num = 5.5m
                                                               },
                                                               new Data_Ndecimal {
                                                                   name = "John", num = 15.5m
                                                               },
                                                               new Data_Ndecimal {
                                                                   name = "Bob", num = null
                                                               } };
                decimal?expected = 10.5m;

                var actual = source.Average((e) => e.num);

                return((expected == actual) ? 0 : 1);
            }
Exemplo n.º 2
0
            // Type: decimal?, selector function is called
            public static int Test8g()
            {
                Data_Ndecimal[] source = new Data_Ndecimal[]{ new Data_Ndecimal{name="Tim", num=20.51m},
                                                new Data_Ndecimal{name="John", num=null},
                                                new Data_Ndecimal{name="Bob", num=2.33m}
            };
                decimal? expected = 22.84m;

                var actual = source.Sum((e) => e.num);

                return ((expected == actual) ? 0 : 1);
            }
Exemplo n.º 3
0
            // Type: decimal, selector function is called
            public static int Test8g()
            {
                Data_Ndecimal[] source = new Data_Ndecimal[]{ new Data_Ndecimal{name="Tim", num=5.5m},
                                                          new Data_Ndecimal{name="John", num=15.5m},
                                                          new Data_Ndecimal{name="Bob", num=null}
            };
                decimal? expected = 10.5m;

                var actual = source.Average((e) => e.num);

                return ((expected == actual) ? 0 : 1);
            }