ASP. NET learning notes (16) structure and class

Source: Internet
Author: User

1. class is a reference type, and struct is a value type.
1. When copying a variable that contains a structure, copying the data will not change the old copy for any modifications made to the new copy;
2. The class is a reference type, and the replication between classes is just a copy reference;

2. class supports inheritance. struct has no inheritance. It cannot inherit from another structure or class, nor itself can it be inherited. It is an implicit sealed, but it supports interface inheritance;

Iii. Internal differences


Iv. Usage
1. Implement a struct function to store data;

2. struct occupies the stack space, so it is only applicable to small data storage;

3. structure data is more efficient;

4. Low Cost of structure when structures represent objects such as vertices, rectangles, and colors;

5. Classes are the best choice for presentation of abstract and multi-level objects;

6. In most cases, this type is only the best choice for some data.
By: dxh_0829

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.