. NET Value Type and reference type,. net reference

Source: Internet
Author: User

. NET Value Type and reference type,. net reference

 

C # Is a Type-safe development language. Its data types include Value Type and Reference Type.

1. Value Type)

  • Character: char U + 0000-U + ffff 16-bit Unicode character (in fact, the character is also an integer)
  • Integer: sbyte, byte, short, ushort, int, uint, long, ulong
  • Float: float (7-bit valid values) and double (15-16-bit valid values)
  • Decimal: 128-bit data type, which has higher precision (28-29-bit valid bits) and a smaller range than the floating point type, and is suitable for financial and currency computing.
  • Boolean: bool (True or False, True or False)
  • Structure: struct
  • Example: enum

Summary of value types:

* ******************* Struct corresponding to the value type *************** *****

Char Char

Sbyte SByte

Byte Byte

Short Int16

Ushort UInt16

Int Int32

Uint UInt32

Long Int64

Ulong UInt64

Float Single

Double Double

Decimal Decimal

Bool Boolean

**************************************** *************

2. Reference Type (the referenced Type variable is also called an object)

  • Class: class
  • Interface: interface
  • Delegate: delegate
  • Object: built-in reference type of. NET
  • String:. NET built-in reference type

Reference Type summary:

Class: Abstraction of objects with the same features

Interface: Unified constraints for seamless data sharing and communication between objects of different classes

Delegate: similar to the pointer in C ++, the method name can be passed as a parameter. The difference is that delegate is type-safe.

Object: base class of all classes in. NET

String: string (a sequence consisting of zero or multiple Unicode characters)

Iii. Comparison between value types and reference types

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.