1, DateTime Digital type
The following are the referenced contents: System.DateTime currenttime=new System.DateTime (); 1.1 to take the current month and day time currenttime=system.datetime.now seconds; 1.2 Take the current year int year =currenttime.year; 1.3 Take the current month int month =currenttime.month; 1.4 Take the current day int day =currenttime.day; 1.5 =currenttime.hour when the current time int is taken; 1.6 Take the current minute int cent =currenttime.minute; 1.7 takes the current second int second =currenttime.second; 1.8 Take the current millisecond int Ms =currenttime.millisecond; (Variables available in Chinese) |
2, int32.parse (variable) int32.parse ("constant")
The following are the referenced contents:
Conversion of character to 32-digit number |
3, variable. ToString ()
The following are the referenced contents:
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 binary) 12345.ToString ("P"); Generate 1,234,500.00% |
4, variable. Length Number Type
The following are the referenced contents:
Length of string: such as: string str= "China"; int Len = str. Length; Len is a custom variable, and STR is the variable name for the measured string. |
5, System.Text.Encoding.Default.GetBytes (variable)
The following are the referenced contents:
codewords conversion to bit code 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 following are the referenced contents: The string is added, (is the + number 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);
The following are the referenced contents:
Intercepts a portion of the string, parameter 1 is the left starting bit, and the parameter 2 is the Intercept number. such as: string S1 = str. Substring (0,2); |
8, String user_ip=request.servervariables["REMOTE_ADDR"]. ToString ();
The following are the referenced contents:
Take remote User IP address |
9, through the proxy server to take remote user real IP address:
The following are the referenced contents: 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"];
The following are the referenced contents: Access session value; For example, assignment: session["username"]= "little Bush"; Take value: Object objname=session["username"]; String strname=objname.tostring (); Empty: Session.removeall (); |
11, String str=request.querystring["variable"];
The following are the referenced contents:
Transfer variables by using hyperlinks. If you are building hyperlinks on any page: click Value in edit.aspx page: String str=request.querystring["Fdid"]; |
12, Doc object. createelement ("new section named");
The following are the referenced contents:
Create a new node for an XML document |
13, the parent node. AppendChild (child nodes);
The following are the referenced contents:
Add a new child node under the XML Document parent node |
14, the parent node. RemoveChild (node);
The following are the referenced contents:
Delete a node |
15, Response
The following are the referenced contents:
Response.Write ("string"); Response.Write (variable); Output to the page. Response.Redirect ("URL address"); Jumps to the page specified by the URL |
16, Char. ISWHITESPCE (string variable, number of digits)--Logical type
The following are the referenced contents:
Check whether the specified position is empty character; Such as: String str= "Chinese people"; Response.Write (Char. Iswhitespace (str,2)); The result is: True, the first character is 0 digits, and 2 is the third character. |
17, Char. Ispunctuation (' character ')--logical type
The following are the referenced contents:
Whether Chag is a punctuation mark such as: Response.Write (char. Ispunctuation (' A ')); return: False |
18, (int) ' character '
The following are the referenced contents:
Turn the characters into numbers, check the code points, and note the single quotes. Such as: Response.Write ((int) ' in '); The result is the code in the word: 20013 |
19, (char) code
The following are the referenced contents: Turn the numbers into characters and look up the characters represented by the code. Such as: Response.Write ((char) 22269); Return to the word "state". |
20, Trim ()
The following are the referenced contents:
Clear a space before and after a string |
21, string variables. Replace ("substring", "Replace with")
The following are the referenced contents:
String substitution Such as: String str= "China"; Str=str. Replace ("Country", "central"); Change the country word to the word Response.Write (str); The output is "central" Another example: (This very practical) String Str= "This is <script> script"; Str=str. Replace ("<", "<font><</font>"); Replace the left angle bracket with <font> < and </font> (or change to, but it will be restored after the XML has been saved) Response.Write (str); Display as: "This is <script> script" If you do not replace the,<script> will not appear, if it is a script, will run, and after the replacement, the script will not run. The value of this code is that you can disable all HTML tags in one text, display them all, and protect your interactive site. Concrete implementation: Add your Form submit button script with the following code: String Strsubmit=label1. Text; Label1 is the ID of the control you want the user to submit data to. Strsubmit=strsubmit.replace ("<", "<font><</font>"); Then save or output strsubmit. You can also use this method to easily implement UBB code. |
22, Math.max (I,J)
The following are the referenced contents:
Take the maximum value in I and J such as int x=math.max (5,10); X will take a value of 10 Add a bit of it. 23. String contrast ... Add a little. |
23, string contrast is generally used: if (STR1==STR2) {}, but there are other ways:
The following are the referenced contents:
(1), String str1; str2 Syntax: STR1. EndsWith (STR2); __ The string str1 whether to end with a string str2 returns a Boolean value. For example: if (str1. EndsWith (STR2)) {Response.Write ("string str1 is terminated" by "+str2+");} (2), Syntax: STR1. Equals (STR2); __ Detect string str1 is equal to String str2, return boolean value, usage ibid. (3), Syntax Equals (STR1,STR2); __ Detect string str1 is equal to String str2, return boolean value, usage ibid. |
24, IndexOf (), LastIndexOf ()
The following are the referenced contents:
Finds the location of the first (last) occurrence of a specified character or string in a string, returning the index value, such as: Str1. IndexOf ("word");//Find the index value (position) of the word in str1 Str1. IndexOf ("string");//Find the index value (position) of the first character of the string in str1 Str1. IndexOf ("string", 3,2), and/or from the str1 4th character, look for 2 characters, find the index value of the first character of "string" in str1 (position) |
25, Insert ()
The following are the referenced contents:
Inserts a specified character in a string that specifies the index bit. Such as: Str1. Insert (1, "word"); in str1 the second word entered prompt inserted "word", if str1= "China", inserted after "Chinese word state"; |
26, PadLeft (), PadRight ()
The following are the referenced contents:
Adds a space or char character to the left (or right) of the string so that the string reaches the specified length, such as: <% String str1= "Chinese"; Str1=str1. PadLeft (10, ' 1 '); No second parameter is plus space Response.Write (STR1); The result is "1111111 Chinese" with a string length of 10. %> |
27. Remove ()
The following are the referenced contents:
Deletes the specified number of characters starting at the specified location String comparisons are generally used: if (STR1==STR2) {}, but there are other ways: |