namespace TestEqual
{
class Program
{
static void Main(string[] args)
{
Point2D a = new Point2D
{
X = ,
Y =
}; Point2D b = a; CallEquals(a, b);
a.Equals(b);
} public static void CallEquals<T>(T instance, T other)
{
instance.Equals(other);
}
} public struct Point2D
{
public int X;
public int Y; public override bool Equals(object obj)
{
if (!(obj is Point2D)) return false;
Point2D other = (Point2D) obj;
return X == other.X && Y == other.Y;
} public bool Equals(Point2D other)
{
return X == other.X && Y == other.Y;
}
}
}
CallEquals(a, b);  走 public override bool Equals(object obj)
a.Equals(b); 走 public bool Equals(Point2D other)
如果 struct Point2D 继承 IEquatable  则都会走 public bool Equals(Point2D other) 可以避免一次装箱
 

最新文章

  1. [译]用AngularJS构建大型ASP.NET单页应用(一)
  2. MVC WebAPI中响应客户端请求返回图片
  3. VS属性页的目录类型
  4. BZOJ3172[Tjoi2013]单词 题解
  5. SQL Server临界点游戏——为什么非聚集索引被忽略!
  6. 43.Android之ListView中BaseAdapter学习
  7. 让IE6下支持固定定位
  8. QStringList与QString互转
  9. ECSHOP在线手册布局参考图--商品详情页 goods.dwt
  10. Jemter
  11. 写一个Windows上的守护进程(6)Windows服务
  12. C语言 - 大小端问题
  13. 将本地代码上传到github
  14. python 基于机器学习识别验证码
  15. windows eclipse直接访问远程linux hadoop开发环境配置(符合实际开发的做法)
  16. loadrunner controller如何执行测试
  17. thinkphp5开发的网站出现”No input file specified”(php版本5.6.27)
  18. springcould
  19. 纯SVG实现的Loading动画,拿走不谢
  20. Python学习---抽屉框架分析[ORM操作]180314

热门文章

  1. 安装 svn
  2. Python使用os.listdir()函数来获得目录中的内容
  3. first os
  4. 网络请求 get post
  5. 数据库连接池c3p0的设置
  6. 最大独立集 HDU 1068
  7. bmp文件格式详细解析
  8. MFC下对串口的操作以及定时器的调用
  9. boost ASIO实例
  10. Intersecting Lines POJ 1269