C # Reference types and value types

Source: Internet
Author: User

C # Reference type and value type 1 differ:

The value type is stored on the stack of memory, and the reference type stores a reference on the memory stack, storing a specific value on the heap.

2 Value type:
// value types: System.ValueType inheritance and System.Object            int m; // formal Name: System.Int32            BOOL true ;            MyStruct MyStruct;            MyEnum MyEnum;

Enum Explanation:

 Public enum  0,// default is 0, can also be modified to 1, then the value will be incremented in turn.  Tuesday} can also inherit the enum from the short type, and the contents will change accordingly. 

Enum Output:

Console.WriteLine (myenum.monday);  // Output Monday Console.WriteLine ((int) myenum.monday);  // Output 0
3 reference types

Include object, string, dynamic

3.1 Object

Object New Object // normal wording Object New Object (); // capitalization is also correct, equivalent to system. Object
String = Determines whether the content is equal
Object (String) = = Determines the address because it is a reference type, and string is an application type, but is overloaded.

3.2 String,class,interface

C # Reference types and value types

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.