国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【轉載】#402

2019-11-17 03:18:20
字體:
來源:轉載
供稿:網友

【轉載】#402 - Value Equality vs. Reference Equality

When we normally think of "equality",we're thinking of value equality - the idea that the values stored in two different objects are the same. This is also known as equivalence. For example, if we have two different variables that both store an integer value of 12, we say that the variables are equal.

1 int i1 = 12;2 int i2 = 12;3 4 // Value equality - evaluates to true5 bool b2 = (i1 == i2);

The variables are considered "equal", even though we have two different copies of the integer value of 12.

We can also talk about reference equality, or identity - the idea that two variables refer to exactly the same object in memory.

1 Dog d1 = new Dog("kirby", 15);2 Dog d2 = new Dog("kirby", 15);3 Dog d3 = d1;4 5 bool b1 = (d1 == d2);   // Evaluates to false6 bool b2 = (d1 == d3);   // Evaluates to true

In C#, the == Operator defaults to using value equality for value types and reference equality for reference types.

原文地址:#402 - Value Equality vs. Reference Equality


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴青县| 宽甸| 莎车县| 西畴县| 芜湖县| 金阳县| 小金县| 兴安县| 读书| 珲春市| 松阳县| 长沙县| 左贡县| 太谷县| 高清| 游戏| 余江县| 广西| 若尔盖县| 伊宁市| 威海市| 宝坻区| 阿拉尔市| 肇庆市| 深泽县| 金寨县| 道孚县| 甘泉县| 东丰县| 汶川县| 犍为县| 潢川县| 阿瓦提县| 子洲县| 怀化市| 宁波市| 康定县| 民乐县| 锦州市| 栾川县| 兴义市|