C # learning notes-array, enumeration, structure, value type, and reference type

Source: Internet
Author: User

I. Array

System. array base class

Multi-dimensional array: rectangular array (Representation Method Different from C language), staggered array (not available in C language)

Ii. Enumeration type

. Net type systems include: Class, interface, enumeration, structure, and delegate.

System. Enum class type

Iii. Structure Type

The keyword struct, "lightweight class type", supports encapsulation, but cannot inherit.

You can use new to create structure variables, but you can also use new

Iv. value types and reference types

System. valuetype system. Object

1. Value assignment

The structure type is the value type, and its value assignment operation creates a new copy in the stack;

For the reference type, only the reference of the variable is referenced in the memory, that is, the reference copy of the actual object in the heap is created in the stack;

The value type that contains the reference type, which is also the value assignment for the reference type included in the value type, is still just copying the reference. To achieve deep replication, you need to implement the iclonable interface.

2. Transfer of reference types

It can be divided into the default Transfer Mode (value transfer) and reference transfer (ref or out keyword)

Pass reference type by value-the caller can change the value of the object's State data, but cannot change the referenced object, that is, cannot change it to a reference pointing to another object.

The reference type passed by reference-it can change the value of State object data, and re-create an object and point to it, that is, it can change the referenced object.

The value type must be derived from system. valuetype; allocated to the stack;

The reference type is derived from any type except system. valuetype. It is allocated to the managed stack.

3. Empty type

? Operator and ?? Operator ......

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.