C # object type

Source: Internet
Author: User

C # value-type data is stored directly in the memory allocated to it, while C # reference type only contains pointers pointing to the location of the stored data.


Basic data type (except string type): including integer, floating point, decimal, and Boolean.

Integer types include sbyte, byte, char, short, ushort, int, uint, long, And ulong;

Float Type: float and double; decimal type: decimal; boolean type: bool type.

Structure Type: struct type.

Enumeration type: enum type.

There are five types of reference: class, interface, delegate, object, string

When the reference type is used as a parameter:
1. When modifying the variable itself, the result is similar to passing the value, that is, the value of the variable before the passing is not changed.
2. When modifying the attributes or fields of a variable, it is passed by reference, which will affect the value of the variable before transmission.
3. When the ref parameter is used, it is the actual reference transfer. Whether the variable itself is modified or the attribute or field of the variable is modified, the value of the variable before transmission will be affected.

Value Transfer: transfers the object's value copy. (That is, the parameter object in the function is a copy of the object in the stack of the object passed during the call .)
Reference transfer: transmits the address of the object in the stack. (That is, the parameter object in the function and the object passed during the call are all objects in the same stack .)

 

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.