C # Basic Learning (0630) object-oriented general study

Source: Internet
Author: User

Object-oriented general learning

1. Encapsulation, inheritance, polymorphism

Fields: Store data, access modifiers should be set to private

Properties: Securing fields, qualifying the values and assignments of fields

New keyword:

1. Open space in the heap (the value of the reference type is in the heap)

2. Create objects in the open space

3. Call the constructor of the object (the constructor has no return value)

This keyword:

1. Object representing the current class

2. Call your own constructor

Constructors: Initializing an object (the process of assigning a value to each property of an object is called an initialization of the object), the constructor is called when the object is created

How to protect a field

1. Get ()

2. Set ()

3. Constructor function

Inherit Learning

Solve the code sink redundancy, achieve polymorphism, increase the code extensibility, easy to maintain

1, single-sex (a class can have only one parent class)

2, Transmission of

The subclass does not inherit the constructor of the parent class, but instead calls the parent class's parameterless constructor by default

C # Basic Learning (0630) object-oriented general study

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.