国产探花免费观看_亚洲丰满少妇自慰呻吟_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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 皋兰县| 普兰店市| 龙井市| 永嘉县| 涿鹿县| 泗阳县| 延安市| 泽州县| 原阳县| 大港区| 天门市| 紫金县| 城口县| 中西区| 陵川县| 民勤县| 桂阳县| 武冈市| 乐平市| 阜康市| 应城市| 房山区| 合山市| 都安| 西华县| 湖南省| 双鸭山市| 兰溪市| 根河市| 英德市| 全州县| 河津市| 二手房| 应城市| 荔浦县| 庄浪县| 内丘县| 清丰县| 崇州市| 长宁区| 辽宁省|