Depth. NET platform and C # programming notes

Source: Internet
Author: User

Fourth. Methods of in-depth classes 1. constructors

Construct: Method name and class name are the same, no return value

No parameter constructor

With parameter constructors

Construct the build policy:

Note: In C #, when we define a class, the default is to generate a class name

A parameterless construct of the same name, but if we customize any one of the parameter constructs, then

The system no longer helps us to generate a non-parametric structure, in real development, we recommend that you define

Two constructors, one without parameters, and one with parameters.

2. Method overloading

Parsing: Multiple methods in the same class that have multiple method methods with the same name but different parameter lists (number, order, type) can form overloads, and the return value type of the method does not have a semi-gross money relationship

The following two methods can form a method overload

public void Say (String name,int age)

{

}

public void Say (int age,string name)

{

}

3. Interaction between objects

Order ordering System

Customer: Point

/* Waiter: Record guest order

* Waiter: Submit menu to Chef

* Chef: Cook according to the menu

* Chef: Remind the food to be finished

* Waiter: Pass the dish (will be done to the customer)

* Customer: Dining

Menu class

Properties: Which customer (client) the menu belongs to

Which table is the menu (ID)

What the customer ordered (meallist)

Customer Category

Method: Order

public void order (waitress Waitress,order order)

Meal

Eat

Waiter class

Record Guest Order

GetOrder (Order order)

Submit a menu to the chef

Sendorder (Chef chef)

Chuan Cai

Transcook ()

Chef class

Get Menu

Cook cooking

Remind the food to be finished

Depth. NET platform and C # programming notes

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.