C # Video-virtual method, virtual

Source: Internet
Author: User

Note: the virtual and abstract methods cannot be declared as private.

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 usingSystem.Collections;7 8 namespaceConsoleApplication19 {Ten  One     classEmployee A     { -         Private string_name; -  the          PublicEmployee (stringname) -         { -              This. _name =name; -         } +  -          Public stringName +         { A             Get at             { -                 return  This. _name; -             } -         } -  -          Public Virtual voidstartwork () in         { -Console.WriteLine ("{0} starts work.", This. _name); to         } +     } -  the     classManager:employee *     { $          PublicManager (stringName):Base(name)Panax Notoginseng         { -              the         } +  A          Public Override voidstartwork () the         { +Console.WriteLine ("{0} starts to Distrubit tasks",Base. Name); -         } $     } $  -     classSecretary:employee -     { the          PublicSecretary (stringname) -:Base(name)Wuyi         { the  -         } Wu  -          Public Override voidstartwork () About         { $Console.WriteLine ("{0} starts to help",Base. Name); -         } -     } -  A     classSeller:employee +     { the          PublicSeller (stringname) -:Base(name) $         { the  the         } the  the          Public Override voidstartwork () -         { inConsole.WriteLine ("{0} starts to sell",Base. Name); the         } the     } About  the     classAccountant:employee the     { the          PublicAccountant (stringname) +:Base(name) -         { the Bayi         } the  the          Public Override voidstartwork () -         { -Console.WriteLine ("{0} starts to compute",Base. Name); the         } the     } the  the     class Program -     { the         Static voidMain (string[] args) the         { theEmployee[] es =Newemployee[5];94  thees[0] =NewEmployee ("Tim"); thees[1] =NewManager ("Gan"); thees[2] =NewSecretary ("Kate");98es[3] =NewSeller ("Jim"); Aboutes[4] =NewAccountant ("Tata"); - 101             foreach(Employee Einches)102             {103 e.startwork ();104             } the 106 Console.readkey ();107         }108     }109}
View Code

C # Video-virtual method, virtual

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.