- Data type conversions:
- 1 using Convert
- 1 For example: string str = "1245.351";
Double db = convert.todouble(str);
- 1 Use cast type, that is, precede the type with parentheses (type name)
- 1 For example: double n1 = (double) N1
- 1 Note: Each type can be converted to a string type.
- 1 For example: string str = n1. ToString ();
String str2 = db. ToString ();
- 1 Using the Parse method
- 1 For example: int n3 = Int.Parse(str);
2. Escape characters:
2.1 When using @, you can save the meaning of the escape character, the original format output!
2.2 Example: String bb = @ "Moon Light Before Bed"
Suspected to be ground frost "; (output here with a carriage return)
string path = @ "f:\c#\ self-taught. avi"; (The output path can be directly output without using a double slash)
3. Placeholder {0}{1} ...
3.1 Placeholder {0:0.00} means:
Double DB2 = 3.333333;
Console.WriteLine ("{0:0.00}", DB2); The placeholder output here is two decimal places
3.2 The position of the placeholder is the title:
The following N1, N2, DB, DB2 correspond to {0},{1},{2},{3}. So the adjustment {0},{1},{2},{3} here in the double quotation mark position can be used for different positions to output
Console.WriteLine ("\n{3};\n{1};\n{0};\n{2}", N1, N2, DB, DB2);
C # Learning Note One (data type, escape character)