首页 > 代码库 > Object.ReferenceEquals

Object.ReferenceEquals

    class Program
    {
        static void Main(string[] args)
        {
            int i = 2,j = 2;
            bool a = Object.Equals(i, j);
            bool b = Object.ReferenceEquals(i, j);
            Console.WriteLine("{0},{1},{2}", a, b,i.Equals(j));
            char[] hello = { ‘h‘,‘e‘,‘l‘,‘l‘,‘o‘};
            string x = "hello", y = new String(hello);
            a = Object.Equals(x, y);
            b = Object.ReferenceEquals(x, y);
            Console.WriteLine("{0},{1},{2}", a, b, x.Equals(y));
            /*
            True,False,True
            True,False,True
            请按任意键继续. . . 
             */
        }
    }

 

Object.ReferenceEquals