Read the Classics-"CLR via C #" (Jeffrey Richter) Notes _ reference type and value type (i)

Source: Internet
Author: User

1. The CLR supports two types: reference types and value types .

2. Most of the types in the FCL are reference types , but the most used in a program are value types .

" Reference type "

  • The memory must be allocated from the managed heap.
  • Each object allocated on the heap has an additional member that must be initialized.
  • Other bytes on the object (set for the field) are always set to zero.
  • When an object is allocated from the managed heap, a garbage collection operation may be enforced.

" Value type "

  • Instances of value types are generally allocated on the thread stack.
  • A variable of an instance of a value type that does not contain a pointer to an instance. The variable itself contains a field.
  • instances of value types are not controlled by the garbage collector, easing the pressure in the managed heap and reducing the number of times the application is garbage collected during the lifetime.
  • Value types are sealed (sealed) to prevent a value type from being used as a base type for any other reference or value type.

Read the Classics-"CLR via C #" (Jeffrey Richter) Notes _ reference type and value type (i)

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.