跟小D每日学口语
摘要: C# 中有两种不同的相等:引用相等和值相等。值相等是大家普遍理解的意义上的相等:它意味着两个对象包含相同的值。例如,两个值为 2 的整数具有值相等性。引用相等意味着要比较的不是两个对象,而是两个对象引用,且两者引用的是同一个对象。这可以通过简单的赋值来实现,如下面的示例所示:C#System.Object a = new System.Object();System.Object b = a;System.Object.ReferenceEquals(a, b); //returns true在上面的代码中,只存在一个对象,但存在对该对象的多个引用:a和b。由于它们引用的是同一个对象,因此具. 阅读全文
posted @ 2012-08-26 22:26 Danny Chen 阅读(697) 评论(0) 推荐(0) 编辑
摘要: using System;namespace CloneFunc{ abstract class Prototype{ string id; public string Id{ get{return this.id;} set{this.id = value;} } public Prototype(string Id){ this.id = Id; } public abstract Prototype C... 阅读全文
posted @ 2012-08-26 22:24 Danny Chen 阅读(243) 评论(0) 推荐(0) 编辑