(4) C # variables, constants, data types, data conversions

Source: Internet
Author: User

1. Variables

The amount of time that can be changed while the program is running

Define and initialize

3.14

2. Constants

The amount of time that a program cannot be changed while it is running, and it can be any basic data type .

such as Integer constants, floating-point constants, character constants, or string constants, as well as enumeration constants

Methods for defining constants

Add a keyword "const" before defining a variable

Const int a=;

3. Data type

There are three types of data in C #, value types, reference types, and pointer types.

Value type

Also known as the basic data type, each value type has a separate memory area to hold its own value, and calls it when it calls his value.

type Description Range Default Value
bool Boolean value True or False False
Byte 8-bit unsigned integer 0 to 255 0
Char 16-bit Unicode characters U +0000 to u +ffff ' + '
Decimal 128-bit exact decimal value, 28-29 significant digits ( -7.9 x 1028 to 7.9 x 1028)/100 to 28 0.0M
Double 64-bit double-precision floating-point (+/-) 5.0 x 10-324 to (+/-) 1.7 x 10308 0.0D
Float 32-bit single-precision floating-point -3.4 x 1038 to + 3.4 x 1038 0.0F
Int 32-bit signed integer type 2,147,483,648 to 2,147,483,647 0
Long 64-bit signed integer type 923,372,036,854,775,808 to 9,223,372,036,854,775,807 0L
SByte 8-bit signed integer type 128 to 127 0
Short 16-bit signed integer type 32,768 to 32,767 0
UInt 32-bit unsigned integer type 0 to 4,294,967,295 0
ULong 64-bit unsigned integer type 0 to 18,446,744,073,709,551,615 0
UShort 16-bit unsigned integer type 0 to 65,535

0

Reference type

(4) C # variables, constants, data types, data conversions

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.