首页 > 其他 > 详细

class struct Equals

时间:2017-04-19 09:24:40      阅读:147      评论:0      收藏:0      [点我收藏+]
{
    class clsA
    {
        private int _i;
        public int I 
        {
            set { _i = value; }
            get { return _i; } 
        }
    }

    struct strctB
    {
        private int _i;
        public int I
        {
            set { _i = value; }
            get { return _i; }
        }
    }

    class Program
    {
        static void Main1(string[] args)
        {
            clsA a1=new clsA();
            a1.I=1;
            clsA a2=a1;
            a2.I=2;
            Console.WriteLine("{0},{1}", a1.I, a2.I);//2,2
            strctB b1=new strctB();
            b1.I = 1;
            strctB b2=b1;
            b2.I = 2;
            Console.WriteLine("{0},{1}", b1.I, b2.I);//1,2
        }
        static void Main(string[] args)
        {
            clsA a1 = new clsA();
            a1.I = 1;
            clsA a2 = new clsA();
            a2.I = 1;
            Console.WriteLine("{0}", a1.Equals(a2));//False
            strctB b1 = new strctB();
            b1.I = 1;
            strctB b2 = new strctB();
            b2.I = 1;
            Console.WriteLine("{0}", b1.Equals(b2));//True
        }
    }
}

 

class struct Equals

原文:http://www.cnblogs.com/sky20080101/p/6731603.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!