One 、System.String class
1, Create string string s = "www.devsiki.com";
2, Get string length s.Length( attribute )
3, Compare whether the string is the same s=="www.devsiki.com"
4, String connection s="http://"+s;
5, Use indexer like syntax to get a character in a string stringName[index] s[0] s[3]
About string character string :string The string created is actually an immutable data type , Once the string object is initialized , The string can't change the content , The above example actually creates a new string , Copy the contents of the old string into the new string . Then assign the reference of the new string to the object of the string .( Modify the given string repeatedly , It's going to be inefficient )
More about strings
1,CompareTo() Method , Compare the contents of strings
2,Replace() Replace a given character or string in a string with another character or string
3,Split() Where a given character appears , Split a string into an array of strings
4,SubString() Retrieve the substring at a given position in a string
5,ToLower() Convert a string to lowercase
6,ToUpper() Convert a string to uppercase
7,Trim() Delete the first and last blanks
8,Concat() Method , Merge strings
9,CopyTo() Method , Copy the characters specified in the string into an array
10,Format() Method , Formatted string
11,IndexOf() Method , The first occurrence of a given string or character
12,IndexOfAny() Method ,
13,Insert() Insert one string instance into the index of another
14,Join() Merge array of strings , Create a new string
Two 、StringBuilder class ( be located System.Text Under the namespace )
1, establish StringBuilder object
StringBuilder sb = new StringBuilder("www.taikr.com");
StringBuilder sb = new StringBuilder(20);
StringBuilder sb = new StringBuilder("www.devsiki.com",100);
About StringBuilder The memory consumption when the object is created
2,Append() Method , Append a character to the current string
3,Insert() Appending a string with a specific format
4,Remove() Delete characters from the current string
5,Replace() In the current string , Replace one character or string with another
6,ToString() Put the present stringBuilder The string stored in , Extract it into an immutable string