C++ learning summary of data types and conversion
- 2020-04-02 03:08:14
- OfStack
I. input/output statements
The Console. ReadLine (); It waits until the user presses enter, reading in one line at a time
The Console. ReadKey (); Waiting for the user to press any key and read in one character at a time.
2. Data type
Main skills:
Value types: int, float, double, char,bool Boolean, datetime Date/time
2. Reference type: string string type
The problem?
A. The difference between string and character: string type USES "", char USES" ", can say that a string is a collection of characters. Eg: string s = "ABC"; Char s1 = 'a', 'b', 'c'.
B. Difference between value type and reference type: value type is cash, which should be used directly; Reference type is the passbook, to use still have to go to the bank to withdraw first.
Three, the conversion mode
1. Implicit conversion: include relationships. Small range can be turned into a large range.
2. Explicit conversion
A. turn with (). Int a; Double b; A, b = (int).
B. use the convert. Int a; Float b; A = the convert. ToInt32 (b); Focus.
C. use the parse. Int a; Double b; A = int. Parse (b);
Four, operators.
The above is all the content of this article, I hope you can enjoy it.