C # Data type (only 5 kinds of course)

Source: Internet
Author: User

int: Represents an integral type with range storage values (2,147,483,648 to 2,147,483,647, 10 digits) inverted: 3, 5, 100, 10, etc.

int number;//A numeric type variable that declares an integer
Number = 1000;
Console.WriteLine (number); //Note this cannot be quoted here

Double represents a decimal type, the range stores values ±5.0x10−324 to ±1.7x10308, such as: 3.14, 1.5, 5.0, etc.

Double pi; //Declare a decimal number type variable
PI = 3.14; //The value can also be integer but must be appended. 0 as 3.0
Console.WriteLine (PI);

char denotes a single character type that is inverted as: ' Male ' a ' a ', etc. note declaring a variable must be a single quotation mark when assigning a value

char sex; //Declare a variable of character type
sex = ' male ';//The variable value of a character type must be enclosed in single quotation marks
Console.WriteLine (Sex);

String represents 0 or more strings that are inverted as: "Computer" "Hello World" "Zhangsan" note when declaring variable assignments, be sure to enclose the value in double quotation marks

String chinaname;//A variable that declares a string
Chinaname = "by three"; the//variable value must be double-quoted and can be 0 or more numeric characters
Console.WriteLine (Chinaname);

Decimal means that a variable of money is higher than a double, for example 5.65 1000 100 Note that if the money has a decimal number, it must be added after the assignment of M

Decimal money;
Money = 5.65m;
Console.WriteLine (Money);
Console.readkey ()

Note Writing a number in a C # development environment that has a decimal type is just a double type, with a decimal followed by M is the decimal type if the money is sometimes an integer then it can be used without m because the integral type is implicitly converted to decimal, and evaluates to decimal. Therefore, you can initialize decimal variables with integers without using suffixes

C # Data type (only 5 kinds of course)

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.