Multi-state abstract class learning

Source: Internet
Author: User

Today is a busy day, 6:30 A.M. get up and then run, and then early self-study. The first class was not a class but the teacher abruptly two classes (slept in the past), and then the teacher did not come, put yesterday to watch the video, noon is really angry school what Hidden Dragon Star speech, made a bad noon, although skipping class to eat rice but still quite angry. With my half a dime of the relationship is not, why I want to go, really wasted my time, make me finally with others complain, make others also angry, forget, so it, feel very annoying.

Back to the bedroom to rest for 10 minutes and go to the Employment class exam, the school Unicom card this month incredibly only 600M traffic, and super, really bored. After the test and come to the library to write less than one hours of code and go to Computer class. Alas. Really annoying, really do not believe this is the university.

OK, no complaining, stick to the code, this is what I wrote in the library today, the Polymorphic abstract class learning part of the code. The practice of abstract classes is done at night, and then the code is pasted up. That's it.

Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; Namespace abstract class {class program    {        static void Main (string[] args)        {            //dog will be called  cat will bark (>^ω^<)            Animal a = new Cat ();//Create Subclass object assignment to Parent class            A.bark ();//representation of the parent class type, in fact the quilt class overrides            Console.readkey ();}    }    Public abstract class animal//abstract classes        //Do not know method with abstract method        //Know method with virtual method    {public        abstract void Bark ();//abstract method, There is no method body    } public    class Dog:animal    {public        override void Bark ()        {            Console.WriteLine (" ");}    public class Cat:animal    {public        override void Bark ()        {            Console.WriteLine ("Meow Meow");    }}}

  

Multi-state abstract class learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.