C # study notes 6, attributes and methods for non-computer professionals

Source: Internet
Author: User

Vi. attributes and Methods

(1) attributes

1. Attribute definition: name of an object's components... Understanding how to add some characters in the game. HP, blue, and so on are attributes.

2. Method for referencing attributes: Object Name. attribute name

3. Property Code: Public string name {get {return **}; set {alue = ....};}

(2) Method

1. Method: The Implementation form of the object, for example, cutting the tool

2. method declaration modifier:

Private is used only within the class.

Public variables and Methods

Protected

Internal

In addition, it can be used in combination:

New

The void method does not return values ....

Static has a return value method, which generally requires return, which can be considered as a variable returned by return.

Virtual

Override

Sealed closed

Abstract

Extern

3. Classification of Methods: static and non-static methods

Static methods must be static and cannot be referenced using this. Non-static methods can reference this;

4. Method overloading: methods with the same name are automatically reloaded according to different parameters.

5. Main method: The program entry point is static, and the internal method cannot be shared by the outside.

C # study notes 6, attributes and methods for non-computer professionals

Related Article

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.