Object.ReferenceEquals

Posted sky20080101

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章