xiacy

导航

3.3.3 用==和 != 进行引用比较

static bool AreReferencesEqual<T>(T first, T second) where T:class
        {
            return first == second;
        }

        static void Main(string[] args)
        {
            string name = "Jon";
            string intro1 = "My name is :" + name;
            string intro2 = "My name is :" + name;
            Console.WriteLine(intro1 == intro2);//输出ture
            Console.WriteLine(AreReferencesEqual(intro1, intro2));//输出flase

        }

 

posted on 2012-05-01 12:42  xiacy  阅读(201)  评论(0编辑  收藏  举报