1, DateTime Digital
System.datetime CurrentTime = new system.datetime ();
1.1 Take the first day of the month
CurrentTime = system.datetime.now;
1.2 taken the previous year
INT year = currenttime.year;
1.3 take the previous month
Int month = currenttime.month;
1.4 Take the day
INT day = currenttime.day;
1.5 Take the current time
INT = currenttime.Hour;
1.6 take the front part
INT = CURRENTTIME.MINUTE;
1.7 take the second second
INT second = currenttime.second;
1.8 takes the current millisecond
INT millisecond = currenttime.millisecond;
(Variable can be available in Chinese)
1.9 Take Chinese Date Display - Annual Month Time
String string = currenttime.tostring ("f"); // does not show second
1.10 Take Chinese Date Show_ 年 月
String stringm = currenttime.tostring ("y");
1.11 Take Chinese Date Show_ 月日
String strmd = currenttime.tostring ("m");
1.12 Take the previous year, the format is: 2003-9-23
String strymd = currenttime.tostring ("d");
1.13 Take the current time, format is: 14: 24
String strat = currenttime.tostring ("t");
2, characters conversion to 32-bit digital type
INT32.PARSE (Variable) Int32.Parse ("constant")
3, variable .tostring ()
Character conversion 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 (16)
12345.Tostring ("P"); // Generate 1,234,500.00%
4, variable .length digital type
Take a string length:
String str = "China";
INT len = str.length; // LEN is a custom variable, Str is a variable name of the string of the measured string
5, word code conversion to a specific code
System.text.Encoding.default.getbytes (variable)
Such as: byte [] Bytstr = system.text.encoding.default.getbytes (STR);
Then you can get the bit length:
Len = byTStr.length;
6, System.Text.StringBuilder ("" ")
The string is added, ( is not the same?)
Such as:
System.text.stringbuilder sb = new system.text.stringbuilder ("");
Sb.Append ("China");
Sb.append ("People"); Sb.Append ("Republic");
7, variable. Substring (parameter 1, parameter 2);
Part of the interception string, the parameter 1 is the left start bit number, and the parameter 2 is a few digits.
Such as: string s1 = str.substring (0, 2);
8, take a remote user IP address
String User_ip = Request.serverVariables ["remote_addr"]. TOSTRING ();
9, through the proxy server to take a remote user real IP address:
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, access the session value
Session ["Variable"];
For example, assign a value:
Session ["UserName"] = "Small Bush";
Value:
Object objname = session ["username"];
String strname = Objname.toString ();
Empty:
Session.removeall ();
11, transfer variables with hyperlink
String str = request.querystring ["variable"];
Take the value in the Edit.aspx page: string str = request.queryString ["fdid"];
12. Create a new node of XML documentation
DOC object .CreateElement ("New Node Name");
13. Add the newly created child node to the XML document parent node
Parent node .Appendchild (child node);
14, delete nodes
Parent node. RemoveChild (node);
15, output to page: Response
Response.write ("string");
Response.write;
Jump to the page specified by the URL:
Response.Redirect ("URL Address");
16, check if the specified position is empty characters
Char.iswhitespce (string variable, bit) - logical
Such as:
String str = "Chinese people";
Response.write (char.iswhitespace (STR, 2)); / / The result is: True, the first character is 0 bits, 2 is the third character.
17, whether the characters are punctuation
Char.ispunctuation ('' ") - logical type
Such as:
Response.write (char.ispuncture ('' a ')); // Return: false
18, turn the character into a number, check the code points, pay attention to the single quotation.
(int) '' Character ''
Such as:
Response.write (int) ''); / / The result is the code of the middle word: 2001319, turn the number to characters, check the characters represented by the code: (CHAR) code
Such as:
Response.write (CHAR) 22269); // Returns the "National" word.
20, clear the string before and after: Trim ()
21, string replacement
String variable.Replace ("Sub-string", "replace")
Such as:
String str = "China";
Str = str.replace ("Country", "Central"); // exchange national characters to CCR
Response.write (STR); // output result is "central"
Another example: (this very practical)