示例#1
0
        public void InterfacesInCollections()
        {
            //arange
            var orange     = new Orange();
            var fruitSalad = new List <IFruit>
            {
                new Banana(),
                new Grape(),
                orange
            };

            foreach (var fruit in fruitSalad)
            {
                Console.WriteLine($"{fruit.Name} {fruit.Peel()}");
                Assert.IsInstanceOfType(fruit, typeof(IFruit));
            }
            Console.WriteLine(orange.Squeeze());
        }