ASP.NET common functions

xiaoxiao2021-03-06  48

ASP.NET Common Function 1, DateTime Digital System.dateTimeCurrentTime = Newsystem.datetime (); 1.1 Net Num-day Diagram CurrentTime = System.dateTime.now; 1.2 Before INT Years = CurrentTime.year; 1.3 Take Current INT month = currentTime.month; 1.4 Take Front Time INT Day = CurrentTime.day; 1.5 Take CurrentTime.Hour; 1.6 Take Prior INT = CURRENTTIME.MINUTE; 1.7 Take Pre-second INT second = CURRENTTIME. SECOND; 1.8 Take the current millisecond INT millisecond = currenttime.millisecond; (variable available Chinese)

1.9 Take Chinese Date Display - Annual Monthly Spectancy StringStry = CURRENTTIME.TOSTRING ("f"); // Do not display second 1.10 to take Chinese dates to display _ year month stringstrym = currenttime.tostring ("y"); 1.11 Take Chinese Date Display _ month stringstrmd = currenttime.tostring ("m"); 1.12 Take Chinese Year StringStrymd = CURRENTTRYMD = CURRENTTIME.TOSTRING ("D"); 1.13 Take the current time, format is: 14: 24Stringst = CurrentTime.toString ("T "); 1.14 Take the current time, format: 2003-09-23t14: 46: 48stringst = currenttime.tostring (" s "); 1.15 Take the current time, format: 2003-09-2314: 48: 30zstringst = CurrentTime. TOSTRING ("U"); 1.16 Take the current time, format is: 2003-09-2314: 48StringstRT = CURRENTTIME.TOSTRINGSTRT = CURRENTTIME.TOSTRINGSTRING ("G"); 1.17 Take the current time, format is: Tue, 23sep200314: 52: 40gmtstringst = CURRENTTIME. TOSTRING ("R"); 1.18 Gets the date Time of the current time n days DateTimeNewDay = DateTime.now.adddays (100); 2, int32.parse (variable) int32.parse ("constant") Character conversion to 32-bit Digital 3, variable.tostring () character type conversion to string 12345.toString ("n"); // Generate 12,345.0012345.toTnow ("c"); // Generate ¥ 12,345.0012345.toString ("e"); / / Generate 1.234500E 00412345.toString ("f4"); // Generate 12345.000012345.toString ("X"); // Generate 3039 (16) 12345.toTString ("p"); // Generate 1,234,500.00% 4, variable .length digital snap strings: stringstr = "China"; intlen = str.length; // LEN is a custom variable, Str is a variable name 5 of the string of the test, System.Text. ENC Oding.default.getBytes (variable) word conversion to a comparison 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 not the same? Such as: system.text.stringbuildersb = newsystem.text.stringbuilder (""); sb.append ("China"); sb.append ("People"); SB.Append (Republic "); 7, variables. Substring (parameter 1, parameter 2); part of the interception string, parameter 1 is the left start bit number, parameter 2 is intercepted.

Such as: strings1 = str.substring (0, 2); 8, stringuser_ip = request.serverVariables ["remote_addr"]. ToString (); Take a remote user IP address 9, through the proxy server to take remote user real IP address: IF ( Request.ServerVariables [ "HTTP_VIA"] = null) {stringuser_IP = Request.ServerVariables [ "HTTP_X_FORWARDED_FOR"] ToString ();.}! else {stringuser_IP = Request.ServerVariables [ "REMOTE_ADDR"] ToString ();.} 10, Session ["Variable"]; Access Session Value; if, assignment: session ["Username"] = "small Bush"; value: objectobjname = session ["Username"]; stringstrname = Objname.toString (); Clear: Session .Removeall (); 11, stringstr = request.queryString ["Variable"]; use hyperlink to transfer variables. Built a hyperlink in either page: Click

Take it in the edit.aspx page

Value: stringstr = request.queryString ["fdid"];

转载请注明原文地址:https://www.9cbs.com/read-110176.html

New Post(0)