ASP.NET function set

xiaoxiao2021-03-05  22

1, DateTime digital system.datetime currenttime = new system.datetime (); 1.1 Net ago, the month-time time, the second currenttime = system.datetime.now; 1.2 Before the year INT year = currenttime.year; 1.3 take the prior month INT month = CURRENTTIME.MONTH; 1.4 Take Front Day INT Day = CURRENTTIME.DAY; 1.5 Take the current INT = CURRENTTIME.HOUR; 1.6 Take the Prior INT = CURRENTTIME.MINUTE; 1.7 Take the second second = CurrentTime.second; 1.8 Take the current millisecond INT millisecond = currentTime.milliseCond; (variable available Chinese)

1.9 Take Chinese Date Display - Annual Month Time String Stry = CURRENTTIME.TOSTRING ("f"); // Do not display second

1.10 Take Chinese Date Show_ 年 年年 String Strym = CURRENTTIME.TOSTRING ("Y");

1.11 Take Chinese Date Show_ 月日 string strmd = currenttime.tostring ("m");

1.12 Take Chinese Year String Strymd = CURRENTTIME.TOSTRING ("D");

1.13 Take the current time, format is: 14: 24 string strat = currenttime.toString ("t");

1.14 Take the current time, format: 2003-09-23T14: 46: 48 string strat = currenttime.tostring ("s");

1.15 Take the current time, format is: 2003-09-23 14: 48: 30Z string strat = currenttime.tostring ("u");

1.16 Take the current time, format is: 2003-09-23 14:48 string strat = currenttime.toString ("g");

1.17 Take the current time, format: Tue, 23 Sep 2003 14:52:40 gmt string strat = currenttime.tostring ("r");

1.18 Get the date of the current time n days after datetime newday = datetime.now.adddays (100);

2, int32.parse (variable) int32.parse ("constant") character type conversion to 32-bit digital

3, variable.tostring () character type 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.toTString ("P"); // Generate 1,234,500.00%

4, variable .length digital snap length: string str = "China"; int LEN = str.length; // is a custom variable, Str is a variable name 5, System. TEXT.Encoding.default.getbytes (variable) word conversion to a ratio code such as: Byte [] ByTSTR = System.Text.Encoding.default.getbytes (STR); then get the bit length: len = bytstr.length;

6, System.Text.StringBuilder ("") String is added, (is 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, parameter 1 is the left start bit number, parameter 2 is intercepted several bits. Such as: string s1 = str.substring (0, 2);

8, string user_ip = request.servervariables ["remote_addr"]. TOSTRING (); Take a remote user IP address

9, pass the proxy server to take a remote user real IP address: if (Request.ServerVariables ["http_via"]! = Null) {string user_ip = request.serverVariables ["http_forwarded_for"]. Tostring ();} else {string user_ip = Request.servervariables ["remote_addr"]. TOSTRING ();

10, session ["Variable"]; Access Session Value;

Value: Object objName = session ["Username"]; string strname = objName.toTString (); empty: session.removeall ();

11, string str = request.QueryString ["Variable"]; use hyperlink to transfer the variable. If you build a hyperlink in either page: Click in edit.aspx page: string str = request.queryString ["fdid"];

12, DOC object .CreateElement ("New Name Name"); Create a new node of XML document

13, parent node .Appendchild (child node); add the new child node to the XML document parent node

14, parent node. Removechild (node); delete node

15, response response.write ("string"); response.write (variable); output to the page.

Response.Redirect ("URL Address"; jump to the page 16 specified by the URL 16, char.iswhitespce - logical check specify whether the location is empty; if: 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. Char.Ispunctuation ('character') - logical symbols are punctuation, such as: response.write (char.ispunctuation ('a')); // Return: false

18, (int) 'characters' turn the character into a number, check the code point, pay attention to the single quotation. Such as: response.write (int) '); / / The result is the code: 20013

19, (char) code converts the number into characters, checks the characters represented by the code. Such as: response.write ((char) 22269); // Returns the word "country".

20, TRIM () Clear String Space

21, string variable.Replace ("Sub-string", "replace") string replacement, such as: string str = "China"; str = str.replace ("Country", "Central"); // Put national characters Change to CCR RESPONSE.WRITE (STR); // Output results are "central"

Another example: (this very practical)

String str = "This is