Пример #1
0
        public static void Aggregate()
        {
            TestSet set          = new TestSet();
            var     filteredSet5 = set.Where(i => i <= 5).Aggregate(1, (acc, s) => acc * s);

            Console.WriteLine("Aggregate-- " + filteredSet5);
        }
Пример #2
0
        //Тоже самое, что и First, FirstOrDefault, SingleOrDefault
        public static void Single()
        {
            TestSet set          = new TestSet();
            var     filteredSet4 = set.Single(s => s % 57 == 0);

            Console.WriteLine("Single--" + filteredSet4);
        }
Пример #3
0
        public static void OrderBy()
        {
            TestSet set          = new TestSet();
            var     filteredSet6 = set.Select(s => new { Number = s, IsEven = s % 2 == 0 }).OrderBy(s => !s.IsEven);

            foreach (var i in filteredSet6)
            {
                Console.WriteLine(i);
            }
        }
Пример #4
0
        public static void WhereSelect()
        {
            TestSet set          = new TestSet();
            var     filteredSet3 = set.Where(s => s > 50).Select(s => new { Age = "new age -- " + s.ToString() });

            foreach (var i in filteredSet3)
            {
                Console.WriteLine(i.Age);
            }
        }
Пример #5
0
        public static void Select()
        {
            TestSet set          = new TestSet();
            var     filteredSet2 = set.Select(s => new { Age = "age -- " + s.ToString() });

            foreach (var i in filteredSet2)
            {
                Console.WriteLine(i.Age);
            }
        }
Пример #6
0
        public static void Where()
        {
            TestSet set = new TestSet();

            var filteredSet = set.Where(s => s > 50);

            foreach (int i in filteredSet)
            {
                Console.WriteLine(i);
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            TestSet set         = new TestSet();
            var     filteredSet = set.Where(s => s % 2 == 0);

            foreach (int i in filteredSet)
            {
                Console.WriteLine(i);
            }
            Console.ReadKey();
        }
Пример #8
0
        public static void Hard()
        {
            TestSet set          = new TestSet();
            var     filteredSet7 = set.Where(s => s % 2 == 0)
                                   .Select(s => "*" + s.ToString() + "s")
                                   .Where(s => s.Length == 4);

            foreach (string i in filteredSet7)
            {
                Console.WriteLine(i);
            }
        }