【转载】#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.
int i1 = ;
int i2 = ; // Value equality - evaluates to true
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.
Dog d1 = new Dog("kirby", );
Dog d2 = new Dog("kirby", );
Dog d3 = d1;
bool b1 = (d1 == d2); // Evaluates to false
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
【转载】#402 - Value Equality vs. Reference Equality的更多相关文章
- [Training Video - 4] [Groovy] Object equality and variable equality check
def x=2 def y=3 if(x == y){ log.info "equal" }else{ log.info "not equal" // prin ...
- 关于C#你应该知道的2000件事
原文 关于C#你应该知道的2000件事 下面列出了迄今为止你应该了解的关于C#博客的2000件事的所有帖子. 帖子总数= 1,219 大会 #11 -检查IL使用程序Ildasm.exe d #179 ...
- First-class function
https://en.wikipedia.org/wiki/First-class_function In computer science, a programming language is sa ...
- C# ==、Equals、ReferenceEquals 区别与联系 (转载)
相关概念 .Net提供了ReferenceEquals.静态Equals,具体类型的Equals以及==操作符这四个判等函数.但是这四个函数之间有细微的关系,改变其中一个函数的实现会影响到其他函数的操 ...
- 【转载】C#相等性比较
本文阐述C#中相等性比较,其中主要集中在下面两个方面 ==和!=运算符,什么时候它们可以用于相等性比较,什么时候它们不适用,如果不使用,那么它们的替代方式是什么? 什么时候,需要自定一个类型的相等性比 ...
- java8-Optional的引入
背景 NPE问题,100%的Java程序员都碰到,并且曾经是心中的痛. 1965年英国TonyHoare引入了Null引用,后续的设计语言包括Java都保持了这种设计. 一个例子 业务模型 Perso ...
- java8-新的日期API
背景 java的日期和时间API设计不理想,java8引入新的时间和日期API就是为了解决这个问题. 老的日期API的核心类 缺点 Date 月从0开始,年最小从1900年开始,没有时区的概念 Cal ...
- Java-Class-FC:java.time.Duration
ylbtech-Java-Class-FC:java.time.Duration 1.返回顶部 2.返回顶部 3.返回顶部 1. /* * Copyright (c) 2012, 2015, ...
- Java-Class-FC:java.util.Optional
ylbtech-Java-Class-FC:java.util.Optional 1.返回顶部 2.返回顶部 1.1. import java.util.Optional; 1.2.1. @Api ...
随机推荐
- Ubuntu 14.04下MySQL服务器和客户端的安装
下面进行简单的配置 安装完成后通过修改/etc/mysql/my.cnf(此文件为mysql的配置文件).将文件中的binding-address=127.0.0.1注释掉.其它配置根据需要更改. H ...
- spring boot 启动时运行代码(2)ApplicationListener
项目概览: StepExecutor: @Component @Slf4j public class StepExecutor implements Runnable { @Autowired pri ...
- Object与String
Object转为String的几种形式 在java项目的实际开发和应用中,常常需要用到将对象转为String这一基本功能.本文将对常用的转换方法进行一个总结.常用的方法有Object.toString ...
- PHP、thinkPHP5.0开发网站文件管理功能(四)下载文件
public function download($currdir = null){ $file = urldecode($currdir); $file = iconv('UTF-8', " ...
- js和jq中常见的各种位置距离之offset和offset()的区别(三)
offsetLeft:元素的边框的外边缘距离与已定位的父容器(offsetparent)的左边距离(不包括元素的边框和父容器的边框). offset().left:返回的是相对于当前文档的坐标,使用o ...
- OCR 维护 crsd.log
###########sample 1 OCR corruption messages are reported in crsd.log, automatic OCR backup is failin ...
- vue interceptors 设置请求头
在main.js添加过滤器,可以 Vue.http.interceptors.push((request,next)=>{ //request.credentials = true; // 接口 ...
- Vue 参数传递及刷新后依旧存在
获取参数方式有两种: 1.params2.query 第一种方式: params this.$router.push({name:'Hello',params:{name:'zs',age:'22'} ...
- Hive学习(三)Hive的Java客户端操作
Hive的Java客户端操作分为JDBC和Thrifit Client,首先启动Hive远程服务: hive --service hiveserver 一.JDBC 在MyEclipse中首先创建连接 ...
- AUTO Uninstaller 下载 (maya/3dsmax/cad/Inventor/Revit uninstall tool 卸载修复工具)
小伙伴是不是遇到 MAYA/CAD/3DSMAX/INVENTOR/REVIT 安装失败或者安装不了的问题了呢?AUTODESK系列软件着实令人头疼,MAYA/CAD/3DSMAX/INVENTOR/ ...