1. Char character type (value type, strcut): Three conversion methods: 1. (INT) Char. 2. Convert. toint (
). 3. iconvertlble, which implements a large number of inter-type conversion operations. The value types in FCL all implement this operation.
It implements several interfaces: icomparable, iconvertible, icomparable <char>, and iequatable <char>.
2. All directly inherited system. object types are reference types. Depressed. System. valuetype is a reference type
Some value types are inherited from them.
Iii. String (sealing class): icomparable, icloneable, iconvertible, icomparable <string>,
Ienumerable <char>, ienumerable, and iequatable <string> interfaces. The string cannot be changed once it is created.
Its size or any string that changes the day. A new string is generated instead of modified.
The original string. For example, if the substring is used to process the string, the original string is not changed. The string processed with the substring is also generated.
A zero-time string is collected when the processing is complete. It is actually the string resident technology.
4. the sorting of strings in different countries is different. When we compare two strings, if the basic country of the language used is not uniform
The same string is not equal for a moment. We use system. thrinding. compareinfo and
Sysetm. globlization. comareinfo ensures that the language to be processed is based on statements in the same country.
5. String resident Mechanism
String S = "hello ";
Console. writeline (object. refreneceequals ("hello", S); returns true. True !!!.
Cause: When CLR is initialized, it creates an internal hash, which is a string with the value directing to the string object in the managed heap.
. At the beginning, the table is empty. When the JIT compiler compilation method is, it searches for every problematic constant string in the hash list.
.CodeFirst, the system looks for the first hello string. Because no hello string is found, it constructs a new string pair in the managed heap.
Image (pointing to this string), and then add the hello string and reference pointing to this object to the hash list. Then the JIT compiler is in the hash
Search for the second hello string. This time, no operation is performed because the string is found. When the code is executed
To reference a hello string, the CLR searches for hello in its internal hash and finds it, pointing to the previously created
The same String object is saved in variable S. When the second line of code is executed, the CLR will look for "hello" inside it again and
Will still be found, so the static refreceneequals that will be passed to the object will be executed the same as the string object, so the returned
True.
However, the following code returns false and true respectively;
String S1 = "hello ";
String S2 = "El ";
String S3 = S2 + "Lo ";
Console. writeline (object. refreneceequals (S1, S3) // false;
Console. writeline (s1.equals (S3); // true;
A Hello is located in the managed heap of S1, and a hello is located in the managed heap of S3, but their values are equal.
False is returned because the dynamically created string is not added to the CLR hash.
True is returned because the two strings actually represent the same character set (true is returned if S3 = "El" + "Lo ).
(Object. refreneceequals is more efficient than s1.equals.
The following code returns true;
String S1 = "hello ";
String S2 = "El ";
String S3 = S2 + "Lo ";
S3 = string. Intern
Console. writeline (object. refreneceequals (S1, S3) // false;
Console. writeline (s1.equals (S3); // true;
6. The Garbage Collector will not release the string objects referenced in the CLR hash, which indicates that the reference of the string object has been hashed to table store.
Only all applications in the processProgramMembers (appdomian) will not hesitate to release these string objects,
Because the string resident is performed by process, that is, a string can be accessed by multiple application domains of the same process,
This saves memory.
7. isinterned: Search for the value in the CLR internal hash: If the CLR internal hash contains this string, isinterned returns
Saves the reference of the string object in the hash. Otherwise, null is returned.
8. stringbulider: When We append a string to it, it checks whether the growth of the value exceeds its capacity. If it exceeds its capacity
Capacity (the default capacity is 16 characters. For example, if the character is 17, the capacity is doubled to 32--64--128-256. If the capacity is set to 100
Double the value of 2), allocate a new array, and copy the original array to the newly allocated array.
, The original array is recycled by GC.
9. The system. iformattble interface provides formatted strings for the Implementation class. The tostring method of this interface accepts two parameters, one
Is format is a string, it tells the method how to format the object, the second parameter is fromatprovider is invalid
System. iformatprovider interface type instance, which provides specific language and culture information for the tosting method. If
A parameter that cannot be recognized by the iformattble interface will throw the system. formtexception exception.
10. datetime: Use D to represent the segment date, d to represent the long date, g to represent the regular date/time format, m to represent the month/day, and s to represent
The date/time format in sequence. t indicates the time format. The u table shows the common time format defined in the iso860 format.
In time format, y indicates year/month.
Enumeration: G indicates the regular format, F indicates the bid format, D indicates the decimal format, and X indicates the hexadecimal format.
Numeric Value Type: format the data in C format, search for decimal format in table D, and expression e in scientific notation.Algorithm, F indicates the fixed point format, and G indicates the regular format,
N indicates the number format, P indicates the percentage format, and r indicates the return format.
Complex formats that cannot be met above can use image format strings. When the format is string, the effect of the string parameter null and G is the same,
Null indicates that the regular format is used for processing.
11. When operating on a string, if its encoding format is not specified, the default is UTF-8 (UTF-represents the Unicode conversion format, that is
Unicode Transformation Format) encoding; UTF-8: can be compressed; and The UTF-16 encodes 16 characters into 2 bytes
, No compression, good performance.
12. codec class: system. Text. encoding, which is an abstract class. System. Text. unicodeing,
System. Text. utf9encoding, system. Text. utf7encoding, system. Text. asciiencoding, etc.
These are all stored in the system. Text namespace and inherited from the class system. Text. encoding and class.
13. The decoder class is used for decoding and is also an abstract base class. When singular bytes appear, the following bytes are saved in the decoder, and
.