Classes in C #

Source: Internet
Author: User

1. Overview of Classes

A class is an active data structure. The data and functions of a program are organized into a collection of packages of logically related data items and functions, called classes.

A class is a data structure that can store data and execute code that contains data members and function members.

Data member: Stores data related to an instance of a class or class. Data members typically emulate the nature of the real-world things that the class represents.

Function members: Execute code, usually simulating the functions and characteristics of real-world things represented by a class.

A C # class can have any number of data members and function members, and members can be any combination of 9-minute possible member types, as follows:

Data members Function members

Field

Constant

Method Property Constructors

destructor operators

Index events

2. Relationship between programs and classes

A running C # program is a set of interacting type objects, most of which are instances of the class. (A running program is a group of interacting objects.) )

3. Declaration Class

When we need to use a class that is not defined by C #, we need to define the class by writing the declaration of the class.

The declaration of a class defines the characteristics and members of the new class, which creates a template for creating an instance that roughly contains the name of the class, the members of the class, and the characteristics of the class.

such as: Class Myexcellentclass//class is the keyword, myexcellentclass is the name of the class

{

Member declaration

}//curly braces contain declarations of members that make up the class body. Class members can be declared in any order within the body of the class, meaning that a member's declaration can refer to another member that is defined in a later class declaration

(Note: Class declarations are sometimes referred to as "class definitions")

Classes in C #

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.