Example #1
0
        public void CallingInterfaceMethods()
        {
            IFruit banana = new Banana();

            string output = banana.Peel();

            Console.WriteLine(output);
        }
Example #2
0
        public void CallingInterfaceMethods()
        {
            // New up an instance of an IFruit
            IFruit fruit = new Banana();  //we are calling Banana BUT will only have the properties of IFruit, can't just call on interfaces like other classes. In this example it will take on the name of the banana put ONLY have access to the IFruit properties in Banana.

            string output = fruit.Peel();

            Console.WriteLine(output);
            Console.WriteLine("The banana is peeled: " + fruit.Peeled);
        }
Example #3
0
        public void CallingInterfaceMethods()
        {
            // New up an instance of an Ifruit
            IFruit banana = new Banana();

            string output = banana.Peel();

            Console.WriteLine(output);

            Console.WriteLine($"The {banana.Name} is peeled: " + banana.Peeled);
        }
Example #4
0
        public void CallingInterfaceMethods()
        {
            IFruit banana  = new Banana();
            Banana banana1 = new Banana();
            // Can't create an interface object
            // IFruit banana = new IFruit();

            // var is like a wildcard argument
            var output = banana.Peel();

            Console.WriteLine(output);

            Console.WriteLine("The banana is peeled: " + banana.IsPeeled);
            Assert.IsTrue(banana.IsPeeled);
        }