1 static unsafe void Main(string[] args) 2 { 3 //StringBuilder 可变 4 //string 每次修改都将产生一个新的字符串(不可变) 5 //*** 所以,对不修改的字符串使用string,否则使用StringBuilder *** 6 7 string s1 = "test"; 8 fixed (char *p = s1) 9 { 10 Console.WriteLine("{0:X}-{1}", (int)p, *p); 11 //45824CC-t 12 } 13 14 s1 = "test2"; 15 fixed (char* p = s1) 16 { 17 Console.WriteLine("{0:X}-{1}", (int)p, *p); 18 //4582504 - t 19 } 20 21 int n1 = 3; 22 Console.WriteLine("{0:X}-{1}", (int)&n1, n1); 23 //8FF454 - 3 24 25 n1 = 9; 26 Console.WriteLine("{0:X}-{1}", (int)&n1, n1); 27 //8FF454 - 9 28 29 30 31 Console.ReadKey(); 32 }