Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the predefined types and reference types in C #

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you the relevant knowledge points about what the predefined types and reference types are in C#. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article, let's take a look at it.

1. Predefined value types

One byte (1Byte) = 8 bits (8Bit)

The BitArarry class can manage the bit Bit.

1. Integer

All shaping variables can be represented in decimal or hexadecimal: long a=0x12AB

If no type is specified for an integer value, it defaults to int type, and you can add the suffix UMagol LMagol UL to indicate other types. Long astat1234L

Sbyte: unsigned form: 1 byte (8 bits), range: 0-255 (28-1), hexadecimal representation: 0x00-0xFFje System.SByte

Byte: signed form: 1 byte (8 bits), range:-128127 (- 215,215-1), hexadecimal representation: 0x00-0xFFMagneSystem.SByte

Short: signed form: 2 bytes (16 bits), range:-32768 ~ 32767 (- 231231-1), hexadecimal representation: 0x0000-0xFFFMagna system. Int 16

Ushort: unsigned form: 2 bytes (16 bits), range: 0-65534 (16-1), hexadecimal representation: 0x0000-0xFFFMagna system. Int 16

Int: signed form: 4 bytes (32 bits), range:-231-231-1 minute system. Int 32

Uint (U): unsigned form: 4 bytes (32 bits), range: 0-232-1 moment system. Int32

Long (L): signed form: 8 bytes (64 bits), range: 263-263-1 system. Int 64

Ulong (UL): unsigned form: 8 bytes (64 bits), range: 0-264-1 moment system. Int64

2. Floating point type

Default to double type for a floating-point value, followed by F and M to specify other types.

Float (F): single-precision floating-point number, 4 bytes (32 bits), decimal precision: 7, range: 1.5'10-45 ~ 3.4 '1038, System.Single

Double: double-precision floating-point number, 8 bytes (64 bits), decimal precision: 15 stroke 16, range: 5.0cm 10-324 ~ 3.4pm 10308, System.Double

Decimal (M): 128bit high precision, 16byte (128bit), decimal precision: 28, range: 1.0mm 10-28 ~ 7.9mm 1028, System.Decimal

Rounding method:

Decimal A1 = decimal.Round (decimal.Parse ("15.252"), 2); / / 12.25decimal a2 = Math.Round (decimal.Parse ("15.256"), 2); / / 15.263, Boolean

Bool: one byte (8 bits), range: true/false,System.Boolean

4. Character type (one character is represented by 2 bytes)

Char:2 bytes (16 bits), range: Unicode characters.

Character representation:

Literally: char axioms x'

Hexadecimal method: char asides'\ x0058'

Show converted integers: char a = (char) 88

Unicode form: char aversion'\ u0058'

2. Predefined reference types: object and string

Note: when string is used as an argument to the function, the passing address still needs to be added "ref" in the form of passing value.

These are all the contents of the article "what are the predefined types and reference types in C#". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report