C # (1): struct

Source: Internet
Author: User
I found that class usage is not a good habit in C #, so now I will study the knowledge of lightweight struct.
Struct (struct) is actually very similar to the class, but there are also many differences. The following is a list:
  1. Struct is a value type, while a class is a reference type. this means that the struct is lightweight and stored on the stack and will not be recycled by the garbage collector. it is more appropriate to use struct when you think about how to organize some data together. you do not need to work with the public.
  2. Struct does not support inheritance and cannot be used for derivation. However, constructors and methods can be implemented.
  3. The struct can have 0 or more constructors and methods, but cannot contain constructors without parameters.
  4. The struct does not have a destructor (because it will not be recycled by the garbage collector ?)

It's only so much. Oh, it seems that I am really stupid. I want to review it later. This is the structure. Remember to use it when appropriate.

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.