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