1. DateTime numeric type
The following is a reference clip:
System. DateTime currentTime = new System. DateTime ();
1.1 take the current year, month, day, hour, minute, second currentTime = System. DateTime. Now;
1.2 take the current Year int Year = currentTime. Year;
1.3 The current Month int Month = currentTime. Month;
1.4 Use the int Day of the current Day = currentTime. Day;
1.5 when the current int value is used: = currentTime. Hour;
1.6 take the current Minute int = currentTime. Minute;
1.7 take the current Second int Second = currentTime. Second;
1.8 take the current Millisecond int Millisecond = currentTime. Millisecond;
(The variable can be in Chinese)
2. Int32.Parse (variable) Int32.Parse ("constant ")
The following is a reference clip:
Convert string to 32-digit font
3. Variable. ToString ()
The following is a reference clip:
Convert string to string
12345. ToString ("n"); // generate 12,345.00
12345. ToString ("C"); // generate $12,345.00
12345. ToString ("e"); // generate 1.234500e + 004
12345. ToString ("f4"); // generate 12345.0000
12345. ToString ("x"); // generate 3039 (hexadecimal)
12345. ToString ("p"); // generate 1,234,500.00%
4. Variable. Length numeric type
The following is a reference clip:
String Length:
For example, string str = "China ";
Int Len = str. Length; // Len is a custom variable, and str is the variable name of the string to be tested.
5. System. Text. Encoding. Default. GetBytes (variable)
The following is a reference clip:
Convert character code to bit code
For example, byte [] bytStr = System. Text. Encoding. Default. GetBytes (str );
Then we can get the bit length:
Len = bytStr. Length;
6. System. Text. StringBuilder ("")
The following is a reference clip:
String addition, (is the same as the + number ?)
For example, System. Text. StringBuilder sb = new System. Text. StringBuilder ("");
Sb. Append ("China ");
Sb. Append ("people ");
Sb. Append ("Republic ");
7. Variable. Substring (parameter 1, parameter 2 );
The following is a reference clip:
Part of the string to be truncated. Parameter 1 is the start number of digits on the left, and parameter 2 is the number of digits to be truncated.
For example, string s1 = str. Substring );
8. String user_IP = Request. ServerVariables ["REMOTE_ADDR"]. ToString ();
The following is a reference clip:
Obtain the IP address of a remote user
9. Obtain the real IP address of the remote user through the proxy server:
The following is a reference clip:
If (Request. ServerVariables ["HTTP_VIA"]! = Null ){
String user_IP = Request. ServerVariables ["HTTP_X_FORWARDED_FOR"]. ToString ();
} Else {
String user_IP = Request. ServerVariables ["REMOTE_ADDR"]. ToString ();
}
10. Session ["variable"];
The following is a reference clip:
Access Session value;
For example, assign a value: Session ["username"] = "";
Value: Object objName = Session ["username"];
String strName = objName. ToString ();
Clear: Session. RemoveAll ();
11. String str = Request. QueryString ["variable"];
The following is a reference clip:
Use hyperlinks to send variables.
For example, create a hyperlink on any page: Click
On the Edit. aspx page, set the value to String str = Request. QueryString ["fdid"];
12. DOC object. CreateElement ("new node name ");
The following is a reference clip:
Create a new node for the XML document
13. parent node. AppendChild (child node );
The following is a reference clip:
Add the new child node to the XML document parent node.
14. parent node. RemoveChild (node );
The following is a reference clip:
Delete a node
15. Response
The following is a reference clip:
Response. Write ("string ");
Response. Write (variable );
Output to the page.
Response. Redirect ("URL address ");
Jump to the page specified by the URL
16. char. IsWhiteSpce (STRING variable, digits) -- Logical type
The following is a reference clip:
Check whether the specified position contains null characters;
For example:
String str = "Chinese people ";
Response. Write (char. IsWhiteSpace (str, 2); // The result is True. The first character is 0, and the second is the third character.
17. char. IsPunctuation ('characters') -- Logical type
The following is a reference clip:
Check whether a character is a punctuation mark.
For example: Response. Write (char. IsPunctuation ('A'); // return: False
18. (int) 'characters'
The following is a reference clip:
Convert the character into a number and check the code. Note that it is a single quotation mark.
For example:
Response. Write (int) 'in'); // The code with the result of a Chinese character: 20013
19. (char) Code
The following is a reference clip:
Convert the number into characters and check the characters represented by the Code.
For example:
Response. Write (char) 22269); // return the word "country.
20. Trim ()
The following is a reference clip:
Clear leading and trailing Spaces
21. string variable. Replace ("substring", "Replace ")
The following is a reference clip:
String replacement
For example:
String str = "China ";
Str = str. Replace ("country", "Central"); // Replace the Chinese character with the central character
Response. Write (str); // The output result is "Central"
Another example is: (this is very practical)
String str = "this is