首页 > 代码库 > class struct Equals
class struct Equals
{ 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。