C # struct

Source: Internet
Author: User

For Structure

1) There can be methods and attributes
2) It is sealed and cannot be inherited, or inherit other structures
3) The structure is implicitly inherited from system. valuetype
4) The structure has a default non-parameter constructor. Each field can be initialized to the default value, but this default constructor cannot be replaced, even if a constructor with parameters is overloaded
5) No structure destructor
6) Except for the const member, the structure fields cannot be initialized when the structure is declared.
7) the structure is a value type. When defined (although the new operator is also used), stack space is allocated and its values are stored in the stack.
8) the structure is mainly used for small data structures. for better performance, do not use too large structures.
9) The close () or dispose () method can be provided for the structure like the class.

If communication programs are often used, the struct is very useful (we recommend that you use the struct to organize data more effectively), and the conversion between the byte data and the struct is also encountered,

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.