Dark Horse programmer C # Learning on the road -- class member

Source: Internet
Author: User

Classes and structures have members that represent their data and behavior. The class members include all the members declared in the class, and all the members declared in all classes in the inheritance hierarchy of the class (except constructors and destructor ). Private Members in the base class are inherited, but cannot be accessed from the derived class.

 

The following table lists the member types that can be included in a class or structure:

 

 
Member Description

Field (C # programming guide)

A field is a variable declared in the class range. The field can be an instance of the built-in numeric type or other classes. For example, the calendar class may have a field containing the current date.

Constant (C # programming guide)

A constant is a field or attribute that sets its value during compilation and cannot be changed.

Attribute (C # programming guide)

Attribute is a method that can be accessed like a field in a class. The attribute can provide protection for class fields to prevent fields from being changed when the object is unknown.

Method (C # programming guide)

Operations that can be performed by the method definition class. The method can accept parameters that provide input data and return output data through parameters. You can also directly return values without using parameters.

Event (C # programming guide)

Events provide notifications to other objects about what happened (such as clicking a button or successfully completing a method. Events are defined and triggered by delegation. For more information, see events and delegation.

Operator (C # programming guide)

Heavy-duty operators are considered as class members. When an operator is overloaded, the operator is defined as a public static method in the class. Predefined operators (+, *, and <) are not considered as members. For more information, see the reload operators (C # programming guide ).

Indexer (C # programming guide)

You can use the indexer to create an index for an object in an array-like manner.

Constructor (C # programming guide)

A constructor is a method called when an object is created for the first time. They are usually used to initialize object data.

Destructor (C # programming guide)

Destructor are rarely used in C. A destructor is a method called by the runtime execution engine when an object is about to be removed from the memory. They are usually used to ensure that all resources that must be released are properly processed.

Nested type (C # programming guide)

Nested types are declared in other types and are generally used to describe only the objects used by the types that contain them.

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.