Ejemplo n.º 1
0
        static void Mains(string[] args)
        {
            var single1 = new SingleValue();
            var single2 = new SingleValue();

            single1.Value = 1;
            single2.Value = 2;

            Console.WriteLine(single1.Sum().ToString());
            Console.WriteLine(single2.Sum().ToString());

            var many1 = new ManyValues();
            var many2 = new ManyValues();

            many1.Add(single1);
            many1.Add(single2);

            many2.Add(single2);
            many2.Add(single2);

            Console.WriteLine(many1.Sum().ToString());
            Console.WriteLine(many2.Sum().ToString());

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public static void Main(string[] Args)
        {
            List <IValueContainer> container = new List <IValueContainer>();

            //First singlevalue
            var cont = new SingleValue();

            cont.Value = 20;
            container.Add(cont);

            //First singlevalue
            var cont2 = new SingleValue();

            cont2.Value = 30;
            container.Add(cont2);

            //Many values
            var manyvalues = new ManyValues();

            manyvalues.Add(100);
            manyvalues.Add(1);
            container.Add(manyvalues);

            //results must be: 20 + 30 + 100 + 1 = 151
            Console.Write(ExtensionMethods.Sum(container));
            Console.ReadKey();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var many = new ManyValues()
            {
                2, 4, 5
            };
            var one = new SingleValue()
            {
                Value = 1
            };
            var three = new SingleValue()
            {
                Value = 3
            };
            List <IValueContainer> list = new List <IValueContainer>()
            {
                one, many, three
            };

            Console.WriteLine(list.Sum());
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            ManyValues mv1 = new ManyValues()
            {
                1, 2, 3
            };
            ManyValues mv2 = new ManyValues()
            {
                4, 5, 6
            };
            SingleValue sv1 = new SingleValue()
            {
                Value = 7
            };
            List <IValueContainer> list = new List <IValueContainer>()
            {
                mv1, mv2, sv1
            };

            Console.WriteLine($"the total value is: {list.Sum()}");
            Console.ReadLine();
        }