C # .NET functions list

xiaoxiao2021-03-06  71

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) 2, int32.parse (variable) int32.Parse ("constant") character type conversion to 32-bit digital 3, variable .tostring () character type conversion Transfer 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 Strings length: such as: string str = "China"; int LEN = str.length; // LEN is a custom variable, Str is a variable name 5, system.text.Encoding.default.getbytes ( Variables) The word conversion is converted to a ratio code such as: byte [] bytstr = system.text.encoding.default.getbytes (STR); then get a bit length: len = bytstr.length; 6, system.text.StringBuilder "" ") The string is added, (the number is not the same?), System.text.StringBuilder SB = New system.text.StringBuilder ("" "); 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 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. Built a hyperlink in either page: Click

Take the value in the Edit.aspx page: string str = request.queryString ["fdid"];

12, DOC object .createElement ("New Node Name");

Create an XML document new node

13, parent node .Appendchild (child node);

Add the newly created 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 specified by the URL

16. Char.iswhitespce (string variable, bit) - logical type

Check if the specified position is empty characters;

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, char.ispuncture ('character') - logical type

Is it a punctuation?

Such as: response.write (char.ispunctuation ('a')); // Return: false

18, (int) 'character'

Turn characters to numbers, check the code points, and pay attention to single quotes.

Such as:

Response.write ((int) '); / / The result is the code: 20013

19, (char) code

Turn the number into characters, check the characters represented by the code.

Such as:

Response.write (CHAR) 22269); // Returns the "National" word.

20, TRIM ()

Clear strings before and after space

21, string variables.Replace ("Sub string", "replace")

String replacement

Such as:

String str = "China";

Str = str.replace ("Country", "Central"); // Replace the national character to CCR Response.write (STR); // The output is "central"

Another example: (this very practical)

String str = "This is

http://blog.9cbs.net/4125/