using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ArraysType { class Program { static void Main(string[] args) { #region 基本類型的最大值和最小值 byte bMax = byte.MaxValue; byte bMin = byte.MinValue; Console.WriteLine(bMax); Console.WriteLine(bMin); short sMax = short.MaxValue; short sMin = short.MinValue; Console.WriteLine(sMax); Console.WriteLine(sMin); int iMax = int.MaxValue; int iMin = int.MinValue; Console.WriteLine(iMax); Console.WriteLine(iMin); char cMax = char.MaxValue; char c = '趙'; Console.WriteLine(c); Console.WriteLine(cMax); #endregion #region string類型的練習 string str1 = "中國人"; string str2 = "中國人"; if (str1 == str2) { Console.WriteLine("\n這兩個相等"); } if ((object)str1 == (object)str2) { Console.WriteLine("他們的object對象相等"); } if (str1.Equals(str2)) { Console.WriteLine("是同一個變量"); } string str3 = str1; str3 = "新中國人"; Console.WriteLine("\nstr1:{0},\nstr3:{1}\n",str1,str3); string str4 = "中"; str4 = str4+"國人"; if (str1 == str4) { Console.WriteLine("這兩個相等"); } if ((object)str1 == (object)str4) { Console.WriteLine("他們的object對象相等"); } if (((object)str1).Equals((object)str4)) { Console.WriteLine("是同一個變量"); } #endregion char cc = 'c'; char a = 'a'; Console.WriteLine("{0},{1}",cc,a); Console.ReadLine(); } } } ==,(object),equals這三者之間的區別在這個程序中有了初步的判斷,對於按值和按引用類型的操做有的真實的程序來比較。記住默認的和加範圍以後的區別,這是關鍵所在。 string類型從來是比較特殊的!