Non-extended members of the string class:
/* Class Method */string. compare; // comparison, returns 1, 0, or-1string. compareordinal; // comparison, returns a string with a different serial number. concat; // merge string. copy; // copy string. equals; // whether the same value is string. format; // format the output string. intern; // string. isinterned; // string. isnullorempty; // whether it is null or emptystring. isnullorwhitespace; // whether it is null, empty, or blank string. join; // connect string. referenceequals; // whether the instance is the same, inherited from the object/* variable */string. empty; // empty string, same as ""/* attribute */length; // * object Method */clone; // reference compareto; // contains; // include copyto; // copy part to the character array endswith; // matches equals at the end; // getenumerator with the same value; // obtains the gethashcode of the enumerator; // GetType; // gettypecode; // indexof; // search for indexofany; // search for insert Based on the character array; // insert isnormalized; // lastindexof; // search for lastindexofany from the right; // search for normalize from the right of the character array; // padleft; // Add spaces or other characters to the left; // remove spaces or other characters from the right; // remove replace; // replace split; // split startswith; // match substring with the beginning; // intercept tolower; // convert to lowercase tolowerinvariant; // convert to lowercase, use the tostring; // toupper; // convert toupperinvariant; // convert to the upper case, and use the TRIM; // Delete the Left and Right blank trimend; // Delete the right blank trimstart; // Delete the left blank
Case sensitivity conversion:
Protected void button#click (Object sender, eventargs e) {textbox1.textmode = textboxmode. multiline; string STR = "ASP. net ", S1, S2, S3, S4; S1 = Str. toupper (); // ASP. net S2 = Str. toupperinvariant (); // ASP. net S3 = Str. tolower (); // Asp.net S4 = Str. tolowerinvariant (); // Asp.net textbox1.text = string. concat (S1 + "\ n" + S2 + "\ n" + S3 + "\ n" + S4 );}
Add or delete blank space:
Protected void button#click (Object sender, eventargs e) {string STR, S1, S2, S3, S4, S5, S6, S7, r = "\ n "; STR = "asp"; S1 = '>' + Str. padleft (Str. length + 4) + 'asp '+ Str. padright (Str. length + 4) + 'asp '+ Str. padleft (7, '*') + '*** ASP' + Str. padright (7, '*') + 'asp ***** '+ Str. trimstart () + 'asp '+ Str. trimend () + 'asp '+ Str. trim () + 'asp
Interception:
Protected void button#click (Object sender, eventargs e) {string STR, S1, S2, r = "\ n"; STR = "123456789"; S1 = Str. substring (2); // 3456789 S2 = Str. substring (2, 4); // 3456 textbox1.text = string. concat (S1 + R + S2 );}
Split:
Protected void button#click (Object sender, eventargs e) {string STR, r = "\ n"; STR = "-3 |-6 |-9 "; string [] arr1 = Str. split ('|'); textbox1.text + = string. join ("/", arr1) + R; //-3/-6 //-9/string [] arr2 = Str. split ('|', ':'); textbox1.text + = string. join ("/", arr2) + R; // 1/2-3/4/5-6 // 7/8-9/string [] arr3 = Str. split ('|', ':', '-'); textbox1.text + = string. join ("/", arr3) + R; // 1/2/3/4/5/6/7/8/9/string [] arr4 = Str. split (New char [] {'|', ':', '-'}); textbox1.text + = string. join ("/", arr4) + R; // 1/2/3/4/5/6/7/8/9/Char [] cs = {'| ',':', '-'}; string [] arr5 = Str. split (CS); textbox1.text + = string. join ("/", arr5) + R; // 1/2/3/4/5/6/7/8/9/string [] arr6 = Str. split (CS, 3); textbox1.text + = string. join ("/", arr6) + R; // 1/2/3 |-6 |-9/string [] arr7 = Str. split (CS, stringsplitoptions. removeemptyentries); textbox1.text + = string. join ("/", arr7) + R; // 1/2/3/4/5/6/7/8/9/string [] arr8 = Str. split (CS, Int. maxvalue, stringsplitoptions. removeemptyentries); textbox1.text + = string. join ("/", arr8) + R; // 1/2/3/4/5/6/7/8/9/string [] arr9 = Str. split (New char [] {'|'}, stringsplitoptions. removeemptyentries); textbox1.text + = string. join ("/", arr9) + R; //-3/-6/-9 /}
Replace:
Protected void button#click (Object sender, eventargs e) {string STR, r = "\ n", S1, S2; STR = "ASP. net 3.5 "; S1 = Str. replace ('. ','-'); // ASP-Net 3-5 S2 = Str. replace ("3.5", "4.0"); // ASP. net 4.0 textbox1.text = string. concat (S1, R, S2 );}
Insert and remove:
Protected void button#click (Object sender, eventargs e) {string STR, r = "\ n", S1, S2, S3; STR = "ASP 3.5"; S1 = Str. insert (3 ,". net "); // ASP. net 3.5 S2 = Str. remove (3); // ASP S3 = Str. remove (0, 4); // 3.5 textbox1.text = string. concat (S1, R, S2, R, S3 );}
Search:
Protected void button#click (Object sender, eventargs e) {string STR = "ASP. net 3.5 "; int N1, N2, N3, N4, N5, N6, N7; n1 = Str. indexof ('. '); // 3 n2 = Str. lastindexof ('. '); // 9 N3 = Str. indexof ('. ', 4); // 9 N4 = Str. indexof ("Net"); //-1 N5 = Str. indexof ("Net", stringcomparison. currentcultureignorecase); // 4 N6 = Str. indexofany (New char [] {'3', '5'}); // 8 N7 = Str. lastindexofany (New char [] {'3', '5'}); // 10 textbox1.text = string. format ("{0} \ n {1} \ n {2} \ n {3} \ n {4} \ n {5} \ n {6}", N1, n2, N3, N4, N5, N6, N7 );}
Include:
Protected void button#click (Object sender, eventargs e) {string STR = "ASP. net 3.5 "; bool B1, B2, B3; b1 = Str. contains ('s'); // false b2 = Str. contains ('s'); // true B3 = Str. contains ("Net"); // true textbox1.text = string. format ("{0} \ n {1} \ n {2}", B1, B2, B3 );}
Matching at the beginning and end:
Protected void button#click (Object sender, eventargs e) {string STR = "ASP. net 3.5 "; bool B1, B2, B3, B4; b1 = Str. startswith ("asp"); // false b2 = Str. startswith ("asp", stringcomparison. currentcultureignorecase); // true B3 = Str. startswith ("asp", true, null); // true B4 = Str. endswith ("5"); // true textbox1.text = string. format ("{0} \ n {1} \ n {2} \ n {3}", B1, B2, B3, b4 );}
Comparison:
Protected void button#click (Object sender, eventargs e) {string str1 = "1001abc"; string str2 = "1001abc"; int N1, N2, N3, N4, N5, N6, N7, n8, strong, N0; n1 = str1.compareto (str2); // 1 n2 = str2.compareto (str1); //-1 N3 = str1.compareto (str1 ); // 0 N4 = string. compare (str1, str2); // 1 N5 = string. compare (str2, str1); //-1 N6 = string. compare (str1, str2, true); // 0 N7 = string. compare (str1, 0, str2, 0, 4); // 0 n8 = string. compareordinal (str1, str2); //-32 bytes = string. compareordinal (str2, str1); // 32 N0 = string. compareordinal (str1, 0, str2, 0, 4); // 0 textbox1.text = string. format ("{0} \ n {1} \ n {2} \ n {3} \ n {4} \ n {5} \ n {6} \ n {7} \ n {8} \ n {9 }", n1, N2, N3, N4, N5, N6, N7, n8, large, N0 );}
Identical or not:
Protected void button#click (Object sender, eventargs e) {string str1 = "ASP. net ", str2 =" ASP. net "; bool B1, B2, B3, B4, B5, B6, B7; b1 = string. equals (str1, str2); // false b2 = string. equals (str1, str2, stringcomparison. currentcultureignorecase); // true B3 = str1.equals (str2); // false B4 = str1.equals (str2, stringcomparison. currentcultureignorecase); // true string str3 = str1; B5 = string. referenceequals (str1, str3); // true str1 = str1.tolower (); str2 = str2.tolower (); B6 = str1 = str2; // true B7 = string. referenceequals (str1, str2); // false textbox1.text = string. format ("{0} \ n {1} \ n {2} \ n {3} \ n {4} \ n {5} \ n {6}", B1, b2, B3, B4, B5, B6, B7 );}
Copy and reference:
Protected void button#click (Object sender, eventargs e) {string str1 = "ABC"; string str2 = string. copy (str1); string str3 = (string) str1.clone (); bool b1 = string. referenceequals (str1, str2); // false bool b2 = string. referenceequals (str1, str3); // true textbox1.text = string. format ("{0} \ n {1}", b1, b2 );}
Copy part to character array:
Protected void button1_click (Object sender, eventargs e) {char [] cs = {'1', '2', '3', '4', '5 ', '6', '7', '8', '9'}; string STR = "abcdefg"; Str. copyto (1, Cs, 3, 2); textbox1.text = string. join ("", CS); // 123bc6789}
Empty or not:
Protected void button#click (Object sender, eventargs e) {bool B1, B2, B3, B4, B5; b1 = string. isnullorempty (null); // true b2 = string. isnullorempty (string. empty); // true B3 = string. isnullorempty (""); // true B4 = string. isnullorwhitespace (""); // true B5 = string. isnullorwhitespace ("123"); // false textbox1.text = string. format ("{0} \ n {1} \ n {2} \ n {3} \ n {4}", B1, B2, B3, B4, B5 );}
Enumerator:
Protected void button#click (Object sender, eventargs e) {// using system is required. collections; string STR = "ASP. net 3.5 "; ienumerator Enum = Str. getenumerator (); While (enum. movenext () {textbox1.text + = string. format ("{0} |", enum. current); // A | S | p |. | n | E | T | 3 |. | 5 | }}
Connection and connection:
Protected void button#click (Object sender, eventargs e) {string STR; STR = string. concat ("asp ",'. ', "Net", "\ x20", 3 ,'. ', 5); // ASP. net 3.5 textbox1.text + = STR + "\ n"; int [] narr = {1, 3, 2, 4, 3, 5}; STR = string. join ("*", narr); // 1*3*2*4*3*5 textbox1.text + = STR + "\ n"; STR = "ASP. net "; STR = string. join ("|", str. toarray (); // A | S | p |. | n | E | T textbox1.text + = STR + "\ n"; string [] Sarr = {"one", "two", "three", "four ", "five", "Six", "Seven", "eight", "Nine", "Ten"}; STR = string. join (";", Sarr, 1, 3); // two; three; four textbox1.text + = STR + "\ n ";}