C # Constants

Source: Internet
Author: User

Constants are fixed values that do not change during the execution of the program. Constants can be any basic data type, such as Integer constants, floating-point constants, character constants, string constants, and enumeration constants.

Constants can be used as regular variables, but their values cannot be modified after they are defined.

The basic types of constants are:

Integer constants: Integer constants can be hexadecimal (beginning with 0x), octal (starting with 0), decimal, integer constants can also have suffixes u and l, suffixes can be uppercase or lowercase, can be any combination, but cannot be repeated

Example:

032UU /* Illegal: cannot repeat suffix */, 30ul/ * unsigned long * /, 30u/* unsigned int */ /c7> , 30l/ * long * *

Floating-point constants: decimal or exponential form to represent floating-point constants

Character constants: A character constant can be a normal character (for example, ' X '), an escape sequence (such as ' \ t '), or a universal character (such as ' \u02c0 ').

String constants: There can be two forms, enclosed in "", or enclosed in @ "".

Enumeration constants

Custom constants: Const <data_type> <constant_name> = value; such as const double PI = 3.14159;

C # Constants

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.