"Learning Notes" C # Object oriented

Source: Internet
Author: User

Object oriented

  • Process-oriented-analyze the steps required to solve the problem and then step through it
  • Object-oriented-decomposing the things that make up a problem into objects
  • An object is used to describe the behavior of something in a problem-solving process.
  • Object-oriented three major features: encapsulation, inheritance, polymorphism
  • Object-oriented program is more reusable, flexible and extensible
  •   
    1 usingSystem;2 namespaceObjectdemo3 {4     //1. Create a refrigerator class by adding fields, properties, and methods to the class so that it has specific characteristics5      Public classRefrigerator6     {7         //Open the refrigerator door .8          Public voidOpen ()9         {TenConsole.WriteLine ("Open the refrigerator door ."); OneConsole.WriteLine ("turn on the light"); A         } -  -         //close the refrigerator door the          Public voidClose () -         { -Console.WriteLine ("close the refrigerator door"); -Console.WriteLine ("Turn off the lights"); +         } -  +         //Tuck sth into the refrigerator A          Public voidPutIn (stringthing) at         { -Console.WriteLine ("put"+ Thing +"Shove it in the freezer ."); -         } -     } -     class Program -     { in         Static voidMain (string[] args) -         { to             //1. Open the refrigerator door +             //2. Tuck the elephant into the refrigerator -             //3. Close the refrigerator door the  *             //process-oriented thinking to achieve $Console.WriteLine ("Open the refrigerator door .");Panax NotoginsengConsole.WriteLine ("to shove an elephant into the freezer"); -Console.WriteLine ("close the refrigerator door ."); the  +             //realization of object-oriented thought A             //2. Solve the problem by combining the behavior of the object therefrigerator RE =Newrefrigerator (); + Re. Open (); -Re. PutIn ("Elephant"); $ Re. Close (); $  - Re. Open (); -Re. PutIn (" Kitten"); the Re. Close (); - Wuyi         } the     } -}

"Learning Notes" C # Object oriented

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.