One, operator
1. Operators and arithmetic expressions
+: addition operator
-: Subtraction operator
*: multiplication operator
/: Multiplication operator
%: Touch operator
2. Relational operators and relational expressions
= =: equals operator
! =: Not equal to operator
<: Less than budget symbol
: Greater than operator
<=: less than equals operator
>=: greater than or equal to budget symbol
3. Operators and Assignment expressions
=: Assign Value
+ =: Plus assignment
-=: minus Assignment
*=: Call Assignment
/=: Except Assignment
^=: Xor or Assignment
%=: Touch the Assigned value
<<=: Left Shift Assignment
>>=: Right Shift Assignment
4. Logical operators and Logical expressions
&: with operator
^: XOR operator
!: Non-operator
|: Or operator
5. Operators and their functions
<<: Left-shift operator
>>: Right-shift operator
&: Bitwise AND operator
^: Bitwise XOR OR operator
!: bit or operator
6. Other operators
++a:
a++:
--a:
a--:
7, ternary operation
a > B? True:false;
Second, string processing
1. Comparing strings
The CompareTo () method is used to compare the equality of two strings. Use Equals to judge comparisons.
2. Locating strings and substring lookup strings
String. IndexOf (); Strictly case-sensitive.
3. Formatting strings
String Format (String,object);
Example:
String str = String.Format ("(C) Currency:{0:c}",-123.23423);
Output result: ¥-123.23423;
4. Separating strings
String[] Split (char[]);
Example:
String str = "hello.world!";
string[] split = str. Split (New char[]{', ', '! '}); /equivalent to string[] split = str. Split ('. ', '! ');
foreach (string s in Split)
{
if (S.trim ()! = "")
{
Console.WriteLine (s);
}
}
Execution Result: Hello
World
5. Inserting a string
A, Insert method
Insert to the specified location:
String str = "This is a girl.";
Index position, parameter
Str =str. Insert (Ten, "ssss");
b, padding string
string PadLeft (int, Char);//Align Left to add string
string padright (int, Char);//right-aligned add string
6. Delete and cut strings
A, delete a string
The Remove () method is used for a character at the specified position of a string.
Usage:
String Remove (Int,int);
b, cut string
String Trim (char[]);//Remove white space from the beginning and end of the string.
String TrimStart (char[]);//Removes the character specified in the character array from the beginning of the string.
String TrimEnd (char[]);//Removes the character specified in the character array from the end of the string.
E, copying strings
String Copy (String);
F, replace string
Replace (); You can replace certain characters or self-strings in a string.
Example:
String Replace (string,string);
Three, constant
1. Constants
Constants, also known as constants, are compiled at a time and are const when the program is run in a constant amount of the process.
To create a constant value that is initialized at run, you should use the ReadOnly keyword. The const keyword is used to create a compile constant number.
2. Access modifiers:
Public: Enables members to access from any location.
Protected: Enables a member to be accessed from within the class that declares it and its derived class.
Private: Enables members to be used only from within the class that declares it.
Internal: Enables a member to declare only its internal access to the assembly.
Iv. Process Control
1. Branch statements
A, if ... else statement
if (BOOL)
{
Execute code block 1;
}else{
Execute code Fast 2;
}
B, switch statement
Swith (condition)
{
Case Condition 1:
Break
Case Condition 2:
Break
Case Condition 3:
Break
Default
Break
}
2. Circular statements
A, for statement
For (initial value, Boolean expression, expression)
{
Execute code quickly;
}
B, while statement
while (BOOL)
{
Execute code;
}
C, do...while statements
do{
Execute code;
}while (bool);//You must write a semicolon or an error later
D, foreach statements
foreach (data type variable name in array and collection)
{
Execute code;
}
3. Exception Handling
A, Try...cath statement
try{
Execute code;
}catch (ArithmeticException ex) {
Gets the current exception message
}
B, try...finally statement
try{
Execute code;
}finally{
Execute this code block if an exception occurs
}
C, Try...catch...finall statements
is usually executed together with try, catch, finally.
E, throw statement
The throw statement is used to throw a throw exception.
Basic knowledge of C #