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. |