C # .NET function and method set

xiaoxiao2021-03-06  39

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 - String StRING STRING STRING Stry = CURRENTTIME.TOSTRING ("f"); // Do not show second 1.10 Take Chinese Date display _ year String strym = currenttime.tostring ("y"); 1.11 Take Chinese date display _ month string strmd = currenttime.tostring ("m"); 1.12 Take Chinese Year String Strymd = CurrentTime.toString ("D") 1.13 Take the current time, format: 14: 24 string strat = currenttime.tostring ("t"); 1.14 Take the current time, format is: 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 Strt = 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 date after N days later Time datetime newday = d ATETIME.NOW.ADDAYS (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.toString ("P"); // Generate 1,234,500.00% 4, variable .length digital tanker length: String str = "China"; int Len = str.length;

// LEN is a custom variable, Str is a variable name 5 of the string of the test, system.text.encoding.default.getbytes (variable) word conversion to a ratio: Byte [] Bytstr = System.Text.Tete [] Bytstr = system.text .Encoding.default.getbytes (STR); then get a bit length: len = byTStr.length; 6, system.text.StringBuilder (") string is added, ( 号 is not the same?) 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); 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 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, session ["Variable"]; Access Session Value; (); Empty: session.removeall (); 11, string str = request.QueryString ["Variable"]; use hyperlink to transfer variables. If you build a hyperlink in either page: in the Edit.aspx page: string str = request.queryString ["fdid"]; 12, DOC Object .CreateElement ("New Number Name"); Create an XML Document New Node 13, Parent Node .Appendchild (child); 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; 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 symbol is punctuation, such as: response.write ('a')); // Return: false 18, (int) 'Character' Characters are converted to numbers, check the code points, pay attention to single quotes. Such as: response.write ((int) '); // The result is the code of the middle word: 20013 19 (Char) Code transfers the number to the character, check the character representative of the code. Such as: response.write ((char) 22269); // Returns the word "country". 20, Trim () Clear String String Space 21, String Variable.Replace ("Sub Stroke", "Replace") String Replacement, String Str = "China"; str = str.replace ("Country" "Central"); // Replace the national word to CCR Response.write (STR); // The output is "central" again, (this very practical) string str = "This is