C # Object-oriented, classes and objects

Source: Internet
Author: User

One, the field of the class

The field of the class is the data within the class.

Second, the method of the class

1, overloading of functions,

How to judge: is composed of two or more functions of the same name, but the function to have a different parameter, or number. (parameter is the input of the function)

            Shuchu ()            {              }            Shuchu (int  a)            {                Console.WriteLine (a);            }            Shuchu (int aaa  string  bbb)            {                  Console.WriteLine (a+")  \ t"+bbb)               }

2, Field of class

The common point is that the variables defined within the class are also called member variables.

3, Package

Right-click on the variable inside the class and select encapsulate.

Once encapsulated, the variable becomes a private, semi-variable inside the class.

Can only be changed by the get (read accessor) set (write accessor). cannot be called directly.

4, static members,

You can only operate with the class name, and you cannot use the class's right-of-way error.

Third, the composition of the class correspondence

Class has a default function with the same name as the class. This function becomes the constituent function of the class

1     Public class Class222 2     {3public            Class222 ()4               {5                  6      }

The difference between a class and an object (personal understanding),

Objects are extended by the class,

There are multiple objects within a class.

The object is the data inside the class.

C # Object-oriented, classes and objects

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.