コード例 #1
0
        private static void ShowWrongCase()
        {
            var persons = new[]
            {
                new { Fruit = "Apple", Name = "Jake" },
                new { Fruit = "Peach", Name = "Tony" },
            };

            // Raw code.
            Console.WriteLine(persons.Where(w => w.Name.In("Apple", "Peach")).Count() == 2);

            // Suggets for step 1.
            Console.WriteLine(persons.Count(w => LinqExtension.In("Apple", "Peach")) == 2);

            // Suggets for step 2.
            Console.WriteLine(persons.Count(w => "Apple".In("Peach")) == 2);
        }
コード例 #2
0
        private static void ShowRightCase()
        {
            var fruits = new List <string>()
            {
                "Apple",
                "Banana",
                "Peach",
                "Orange"
            };

            // Raw code.
            Console.WriteLine(fruits.Where(w => w.In("Apple", "Peach")).Count() == 2);

            // Suggets for step 1.
            Console.WriteLine(fruits.Count(w => LinqExtension.In(w, "Apple", "Peach")) == 2);

            // Suggets for step 2.
            Console.WriteLine(fruits.Count(w => w.In("Apple", "Peach")) == 2);
        }