1.1 display Chinese date -- year, month, and day
String strY = currentTime. ToString (f); // seconds not displayed
1.2 use Chinese date to display _ year and month
String strYM = currentTime. ToString (y );
1.3 retrieve Chinese Date display _ month/day
String strMD = currentTime. ToString (m );
1.4 Chinese year, month, and day
String strYMD = currentTime. ToString (D );
1.5 get the current time, format: 14: 24
String strT = currentTime. ToString (t );
1.6 obtain the current time in the format of 2003-09-23T14: 46: 48
String strT = currentTime. ToString (s );
1.7 obtain the current time in the format of 2003-09-23 14: 48: 30Z
String strT = currentTime. ToString (u );
1.8 The current time. format:
String strT = currentTime. ToString (g );
1.9 take the current time, format: Tue, 23 Sep 2003 14:52:40 GMT
String strT = currentTime. ToString (r );
1.10 obtain the date and time of the current time n days later
DateTime newDay = DateTime. Now. AddDays (100 );
2. Int32.Parse (variable) Int32.Parse (constant)
Convert string to 32-digit font
3. Variable. ToString ()
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? Page specified by URL
4. Variable. Length numeric type
String Length:
For example, string str = programming;
Int Len = str. Length; // Len is a custom variable, and str is the variable name of the string to be tested.
5. System. Text. StringBuilder ()
String addition, (is the same number ?)
For example, System. Text. StringBuilder sb = new System. Text. StringBuilder ();
Sb. Append (programming );
Sb. Append (technology );
Sb. Append (development );
6. Variable. Substring (parameter 1, parameter 2 );
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 );
7. String user_IP = Request. ServerVariables [REMOTE_ADDR]. ToString ();
Obtain the IP address of a remote user
8. Obtain the real IP address of the remote user through the proxy server:
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 ();
}
9. Session [variables];
Access Session value;
For example, assign a value: Session [username] = bush;
Value: Object objName = Session [username];
String strName = objName. ToString ();
Clear: Session. RemoveAll ();
10. String str = Request. QueryString [variable];
Use hyperlinks to send variables.
For example, create a hyperlink on any page: <a href = "http://www.zhmy.com/Edit.aspx? Fbid = 23> "; click </a>
On the Edit. aspx page, set the value to String str = Request. QueryString [fdid].
11. DOC object. CreateElement (new node name );
Create a new node for the XML document
12. parent node. AppendChild (child node );
Add the new child node to the XML document parent node.
13. parent node. RemoveChild (node );
Delete a node
14. Response
Response. Write (string );
Response. Write (variable );
Output to the page.
Response. Redirect (URL address );
Jump to the page specified by the URL