Two. Value types and reference types
2.1 Value types: All numeric types are value types (short int long float double ... ), enumeration, Boolean type, structure
2.2 Reference types: Objects, strings, object, arrays
The value of the 2.2.1 reference type is stored in the heap, and the stack stores only its reference address.
2.2.2 The assignment of a reference type, which is actually a copy of the address
2.3 To invoke a non-static member (field, method) inside a class, you need to call through an object of the class
To invoke a static member inside a class, you just need to call it through the class.
2.4 When instantiating an object of a class, the heap will generate all non-static members (variables, methods) inside the class.
2.5 When you instantiate an object of a class, the object of the class is first retrieved in the heap, and if it exists, a copy
2.6 When you instantiate an object, all members of the class (static or non-static, value type or reference type) are stored in the heap
Three. Crating and unpacking
3.1 Boxing: Value type conversion to reference type
int i=10;
String s=i.tostring ();
Unpacking: Converting a reference type to a value type
String s= "10";
int I=convert.toint32 (s);
3.2 Data type conversions
Implicit conversion: low-precision to high-precision, direct turn
int i=123;
Double b=i;
Explicit conversion: high-precision to low-precision, must indicate the type of target to be converted, due to differences in data, it is possible to lose some of the data
Double x=1223.4;
int A;
a= (int) x;
3.3??
A=b?? C----> B is null, NULL if A=C is not NULL then A=B
String (i)
One. String
1.1 String Transitions to arrays
String s= "ASDFGHK"
Char[] A=s.tochararray ();
1.2 str. Length indicates the number of characters inside the string.
1.3 Once the string object is created, the object cannot be modified.
Two. Common methods
2.1 equals: Determines whether two strings are the same, false if the same return value is True
Console.WriteLine (String.Equals ("AA", "BB"));
2.2 When a class is a static class, all members of the class are static
2.3 Locating strings
Startwith/endwith determines whether a string begins with a string _ (end) and returns a value True/false
Indexof/lastindexof the position of the first (last) occurrence of a specified character or string
2.4 Intercept String Substring
2.5 Inserting and populating strings
2.5.1 Insert Method
String str1 = "HI";
String str2 = "World";
String str3=str1. Insert (1,STR2);
2.5.2 Padleft/padrigth method
String str1= "HI";
String str2=str1. PadLeft (4, ' @ '); -------left to fill to the right.
Console.WriteLine (STR2);
The result is: @ @hi
2.6 Delete and cut string Remove method
2.6.1 Remove (Start delete location, number of deletions)
2.6.2 Trim
1. Remove the front and back spaces
2. Remove special characters
Char[] str1={' @ ', ' # ', ' $ '};
String str2= "@China $#";
String str3=str2. Trim (STR1);
Console.WriteLine (STR3)
Results for China
2.6.3 TrimStart (remove the front space), TrimEnd (remove the trailing space)
2.6.4 CopyTo Method
String str1= "China";
Char[] Str2=new char[100];
Str1. CopyTo (0,str2,0,3);//The starting position of the character (STR1) to be copied, the target array (str2), the specified position in the target array to start, the number of characters to copy
2.7 Replacement string
String str1= "Hello";
String str2=str1. Replace ("ll", "R");
Console.WriteLine (STR2);
2.8 Format upload content to a string
String.Format ("Age is {0}, name is {1}", b);
2015-10-26 c#2