Abstract keyword--abstraction

Source: Internet
Author: User

Code:

1 usingSystem;2 3 namespaceconsole_test4 {5     class Program6     {7          Public Abstract classMyclas8         {9             /// <summary>Ten             ///number attribute and its implementation One             /// </summary> A             Private int_id; -  -              Public intID the             { -                 Get{return_id;} -                 Set{_id =value;} -             } +  -             /// <summary> +             ///name attribute and its implementation A             /// </summary> at             Private string_str; -  -              Public stringStr -             { -                 Get{return_str;} -                 Set{_str =value;} in             } -  to             /// <summary> +             ///abstract method, used to output information -             /// </summary> the              Public Abstract voidShowdiolg ();//abstract method to be in abstract class *         } $ Panax Notoginseng         /// <summary> -         ///inherit the drawing class the         /// </summary> +          Public classTestclass:myclas A         { the             /// <summary> +             ///overriding methods used in abstract classes for output -             /// </summary> $              Public Override voidShowdiolg () $             { -Console.WriteLine (ID +"\ n"+str); -             } the         } - Wuyi         /// <summary> the         ///Main method, master entry of the program -         /// </summary> Wu         /// <param name= "args" ></param> -         Static voidMain (string[] args) About         { $             //instantiating derived classes -TestClass TC =NewTestClass (); -  -             //instantiating an abstract class using a derived class object AMyclas MC =TC; +  the             //using abstract class objects to access numbering properties in abstract classes -Mc.id = -; $  the             //using abstract class objects to access name attributes in abstract classes theMc.str ="Kaidi"; the  the             //to invoke a method in a derived class using an abstract class object - Mc.showdiolg (); in  the Console.readkey (); the         } About     } the}

Complete.

Abstract keyword--abstraction

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.