C # variable 2

Source: Internet
Author: User

| Copyright Notice: This article for Bo Master original article, without Bo Master permission not reproduced.

Data type:
(1), Value type

1 type name CTS type description Range
2 sbyteSystem.SByte 8-bit signed integer-2^7~2^7-1(- -~127)3 ShortSystem.Int16 16-bit signed integer-2^ the~2^ the-1(-32768~32767)4 intSystem.Int32 32-bit signed integer-2^ to~2^ to-15 LongSystem.Int64 64-bit signed integer-2^ the~2^ the-16 byteSystem.Byte 8-bit unsigned integer0~255(0~2^8-1)7 ushortSystem.UInt16 16-bit unsigned integer0~2^ --1(0~65535)8Uint System.UInt32 32-bit unsigned integer0~2^ +-19Ulong System.Int64 64-bit unsigned integer0~2^ --1Ten floatSystem.Single 32-bit single-precision floating-point number ±1.5*Ten^- $~±3.4*Ten^ - One DoubleSystem.Double 64-bit single-precision floating-point number ±3.0*Ten^-324~±1.7*Ten^308 A decimalSystem.Decimal 128-bit single-precision floating-point number ±1.0*Ten^- -~±7.9*Ten^ -

(2), character type

1    type name                CTS Type value                                    domain 23    char                   System.Char                      represents a 16-bit Unicode character 

(3), Boolean type

1 type name                CTS type                                    Domain
2 BOOL System.Boolean true/False

(4), enum type (enum)

The 1 enumeration is actually an integer type that defines a set of basic integer data and can assign a memorable name to each integer.

(5), reference type

1 type name                CTS type                                    Description 2    3object                System.Object                    base type, other types in the CTS derive from it  45 string                system.string                     Unicode string type

Learning a Word:console.readline ();
Console.ReadLine (); indicates that a user enters a string of characters from the keyboard, similar to the C + +,cin and scanf in the C language, but the difference is that all the user input

The content will be a string type, so when you receive user input, you should define a variable of type string to receive the user input.

1 string Input;           2 // here, if you change the type of input from string to int or any other type, you will get an error 3 Input = console.readline (); 4 5 Console.WriteLine (Input);

Escape characters:
The format of the escape character: \ + character, when we need to enter some special characters in the string, you can use the escape character to enter (such as: half-width quotation marks, line wrapping, backspace ... ), Common

The escape character is:\ n means that the newline \b means that the backspace \ \ Represents the horizontal tab \ "represents the character " "number \ \ denotes the character \ backslash.


Attention:
@ means that there are two meanings in front of the string
". String if there is \, then ignore \, no longer interpret it as escape character
". Use strings to wrap a line definition

1 namespacetest4_ Escape Character2 {3     class Program4     {5         Static voidMain (string[] args)6         {7             //The input statement in C #: Console.ReadLine (), which acts like scanf in the Cin,c language in C + +8             //Note: *console.readline (); When receiving user input, the entire content entered by the user is treated as a string type, as follows:9             stringInput;Ten             //here, if you change the type of input from string to int or any other type, you will get an error OneInput =console.readline (); A Console.WriteLine (Input); -  -             //ERROR the             //int inputerrortest; -             //inputerrortest = Console.ReadLine (); -             //Console.WriteLine (inputerrortest); -              +             //format of escape character: \ + character -             //When we need to enter some special characters in the string, we can use the escape character to enter (for example: half-width quotation mark, line break, backspace ...) +             //The common escape characters are: \ n means that the newline \b means that the backspace \ t represents the Horizontal tab \ "represents the character" "number \ \ denotes the character \ Backslash A             //Note the point: at             //(1), @ means that there are two meanings in front of the string -             //". String if there is \, then ignore \, no longer interpret it as escape character -             //". Use strings to wrap a line definition -  -             //output "" Number in output statement -             //output "" number, can not directly Console.WriteLine ("I love my beautiful Big China" "); in             //instead, say "\" output, tell the compiler to output quotes, otherwise the quotation marks will be paired with the preceding quotation marks , and an error occurs. -Console.WriteLine ("I love my beautiful big china \ "\"");  to              +             //Use of @ -             //Error code: Console.WriteLine ("C:\Program Files (x86) \foxit software\foxit reader\skins\normal\orange"); the             //If there is an @ sign in the output statement, to output the "" number, we can use two double quotation marks instead of a double quotation mark *Console.WriteLine (@"C:\Program Files (x86) \foxit Software\foxit Reader\skins\normal\orange"); $ Panax NotoginsengConsole.WriteLine (@"C:\Program Files -  the (x86) \foxit Software\foxit Reader + line Break Definition A Skins\normal\orange"); the  +Console.WriteLine (@"C:\Program Files (x86) \foxit software\foxit "" Reader\skins\normal\orange"); -  $ Console.readkey (); $         } -     } -}

C # variable 2

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.