. NET data type (class)

Source: Internet
Author: User

 

    • Class

the class is the most powerful data type in C. Like a structure, classes also define data and behavior of data types. Then, the Program personnel can create objects for such instances. Different from the structure, classes support inheritance, and inheritance is the basic part of object-oriented programming.

    • Constructor

A constructor is a class that is executed when an object of a given type is created. Method, which is called at runtime rather than during compilation, including instance constructor and static constructor. The constructor has the same name as the class and cannot return values.

      • Constructor chain

use the this keyword to call the concatenation constructor, you can use optional parameters to replace the constructor chain, but the syntax of optional parameters can only be in. run in the net4 environment.

      • Static Constructor
    • Destructor)

The Destructor is used to analyze the instance of the class and re-object finalize () method.

The Destructor cannot be defined in the structure. Only destructor can be used for classes.

A class can have only one destructor. The Destructor cannot be inherited or overloaded. You cannot call the destructor. They are automatically called. Destructor are implicitly protected without modifiers or parameters.

    • keywords
      • New: Create an object
      • This: Instance Object
      • base: Base Class Object
      • static: static
    • default access modifier
      • class: Implicit
      • default constructor: implicit private
    • Object

Class instantiation, using the new keyword for instantiation

      • Object initializer

only a small number of Code can be used to create an object and set some attributes and public fields. The object is initialized using {}, A list of specified values separated by commas. Each member in the initialization list is mapped to a public field or public attribute in the object being initialized.

        • Sample Code
Point P = new point {x = 1, y = 2 };
    • Object
The object type is the alias of the object in. NET Framework. In the unified type system of C #, all types (pre-defined type, user-defined type, reference type and value type) are inherited directly or indirectly from the object. Any type of value can be assigned to an object-type variable.
    • Packing
The process of converting a value type variable to an object is called "Packing ".
    • Unpack
The process of converting an object type variable to a value type is called "unpacking ".

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.