Probe into the source--system.string of class library

Source: Internet
Author: User

One, MSDN description

String class: Represents text, which is a series of Unicode characters

Namespaces: System

Assembly: mscorlib.dll

Inheritance Relationship:

Note:

1. A string is an ordered collection of Unicode characters that is used to represent text. A string object is an ordered collection of System.Char objects that represent strings.

2. The value of the string object is the contents of the ordered collection, and the value is immutable, so the string object is called an immutable

stringSTR1 ="3"+"b"The sentence is designed to 1 string objectsusingSystem;classapp{Static voidMain () {//This piece of code creates 3 string objects        stringstr ="a"; STR+="1"; STR+="3"; Console.WriteLine (str.    Length); }}/*. Method private hidebysig static void Main () CIL managed{. entrypoint//code size (0x20). Maxstack 2. Local S init (string v_0) Il_0000:nop il_0001:ldstr "A" il_0006:stloc.0 il_0007:ldloc.0 il_0008:ldstr "                                                              1 "Il_000d:call string [Mscorlib]system.string::concat (String, String) il_0012:stloc.0 il_0013:ldloc.0 il_0014:ldstr "3" Il_0019:call string [mscorlib] System.string::concat (String, string) il_001e:stloc.0 Il_ 001f:ret}//End of method App::main*/The ldstr instruction above is the instruction to create a string object on the heap
View Code

3. For places where string values need to be modified frequently, use the System.Text.StringBuilder

4. String and string relationships: string is a string (System.String) alias in C #

Common attributes (with fields) and methods

Property:
Length: Gets the number of characters in the current String object
Empty: Represents a null string. This field is read-only.

static method:
IsNullOrEmpty
Isnullorwhitespace
Format
Compare

Instance method
Contains whether a string is included
Startwith the beginning of a string
Endwith End With a string
equals is equal to a string of XXX
IndexOf returns the first index matching a specified character (string)
Trim remove the kinsoku whitespace characters
Split splits the original string into a character array with a substring
Substring intercept string
ToLower variable Lowercase
ToUpper to uppercase
Equals (String) Determines whether this instance has the same value as another instance

Not finished

Probe into the source--system.string of class library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.