Home > Net >  C # random notes: composite operator and escape character, formatting a placeholder
C # random notes: composite operator and escape character, formatting a placeholder

Time:10-05

Composite operator

The +, -, *,/

% more than take on both sides of the operator which can be an integer, or floating-point Numbers,

Increasing operator + + + + in before gagarin, + + the back after gagarin

- decrement operators - reduction, reduction of earlier - in the relief after

For example:

Int a=3; Int a=3;

Int b=0; Int b=0;

B=+; B=+ + a;

B=3, a=4; B=4, a=4;

Expression: constants, variables and formulas of operators,

Operation result be out of the return value

//read input one character at a time, flat returns to its corresponding ASCLL code value

Int ri=Console. The Read ();

Console. WriteLine (ri);

For example:

Output method, print and line breaks

Console. WriteLine ();

Output method, only print non-breaking

The Console. The Write ();

The operation of the string

Suitable for the operator of the string to
+.
Strings together, that is, joining together the two strings;

String to add value, to convert the numeric string first, and then in the string concatenation

Escape character

If the string in front of the @ symbol, the escape character failure

\ n

\ b

\ \

\ "

\ '

\ t

Formatting output (placeholder)

{}

Keep floating point is to use the

Keep a digits: F

: P percent

C: money symbol

For example code:

Float age=26.500000 f;

String name="hou central scroll";

Console. WriteLine (" name: {0}, \ nage: {1: f} ", name, age);

Console. WriteLine (" ratio value: {0: p32} ", 1.000 m/3);

The value of the ABC input method is type int

CodePudding user response:

CodePudding user response:

CodePudding user response:

  •  Tags:  
  • C#
  • Related