C # appearance of basic,

Source: Internet
Author: User

C # appearance of basic,

1. What is c #

C #, read as "C sharp", is an object-oriented high-level programming language released by Microsoft and runs on. NET Framework. C # integrates the simple visual operations of VB and the high operating efficiency of C ++, with its powerful operation capabilities, elegant syntax style, innovative language features, and convenient support for component-oriented programming. NET Development preferred language.

Two types of appearance

Definition: A class is a blueprint or prototype that defines the variables and methods of all objects of the same class. For example, you can set up a definition containing the table class. This class defines and provides implementation of instance methods (such as record time and reset time.

Class will provide the value of each instance variable. Therefore, after you create a table class, you must instantiate it before using it. When creating an instance of the watch class, an object of the watch type is created. Then, we define the system class to create instance variables and allocate memory at the same time. We can call the instance methods and some functions of the table class. Of course, apart from instance variables and methods, classes can also define class variables and class methods. Class variables and methods can be obtained from the instance of the class or directly from the class. Class methods can only be used as class variables.

2.1 Benefits

Objects provide modeling and Information Hiding benefits. Class provides the advantages of reusability. Watch-makers reuse the same blueprint over and over again to create a large number of watches. We use the same class, that is, the same Code creates an object over and over again.

2. Relationship between classes and objects

A class is the abstraction of an object, and an object is a specific instance of a class. Classes are abstract and do not occupy memory, while objects are specific and occupy storage space. A class is a blueprint for creating objects. It is a software template that defines methods and variables included in a specific type of objects.

Member functions of the 2.3 class

The nature of a member function: A member function of a class (class function for short) is a type of function. It also has return values and function types.

The difference between it and a general function is that it is a member of a class and appears in the class body. It can be specified as private, public, or protected ). When using a class function, pay attention to the permission to call it (whether it can be called) and its scope (the range of data and functions that can be used by the function ). For example, a private member function can only be called by other member functions in the class, but cannot be called outside the class. Member functions can access any member (including private and public) in this class and reference valid data in this scope. The general approach is to designate the member functions that need to be called by the outside world as public, they are the external interfaces of the class. However, it should be noted that not all member functions must be specified as public. Some functions are not prepared for external calls, but called for member functions in this class. They should be specified as private. This function is used to support operations of other functions. It is a utility function of other members of the class. users outside the class cannot call these private tool functions. A member function of a class is a very important part of the class body. If a class does not contain a member function, it is equivalent to a structure in C language and does not reflect the role of the class in object-oriented programming.

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.