如何检查wo对象是否相等? [英] How to check wo object are equal?

查看:68
本文介绍了如何检查wo对象是否相等?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


检查两个物体是否相等的正确方法是什么?

我的意思并不仅仅是对象类型,而且对象价值'


thnaks求助

问候

serge

Dear all,

What is the proper way to check if two object are equal ?
I do not mean equal on Object type only but also object value''s

thnaks for help
regards
serge

推荐答案

Hello serge,


实现IComparable接口.CompareTo()实现成员比较

scDear all,

sc>

sc检查两个对象是否相等的正确方法是什么?我没有

scmean仅限于对象类型而且对象值''

sc>

scthnaks for help

scregards

scserge

---

WBR,

Michael Nemtsev [C#MVP] ::博客: http://spaces.live.com/laflour


有时一个人仍然忠实于一个事业只因为它的对手不会因为b $ b不再是平淡的。 (c)Friedrich Nietzsche
Hello serge,

Realize IComparable interface where in .CompareTo() implement members comparing
scDear all,
sc>
scWhat is the proper way to check if two object are equal ? I do not
scmean equal on Object type only but also object value''s
sc>
scthnaks for help
scregards
scserge
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


serge calderara写道:
serge calderara wrote:

亲爱的,

检查两个对象是否相等的正确方法是什么?

我的意思并不仅仅是对象类型,而是对象值'


thnaks求助

问候

serge
Dear all,

What is the proper way to check if two object are equal ?
I do not mean equal on Object type only but also object value''s

thnaks for help
regards
serge



使用关键字* is *


-

Texeme Construct
http://you-read-it-here-first.com


>什么是正确的方法检查两个物体是否相等?
>What is the proper way to check if two object are equal ?

>我的意思不仅仅是对象类型,而且对象值''
>I do not mean equal on Object type only but also object value''s



如果类型覆盖了Object.Equals方法(并且它应该如果它支持值比较),你可以调用它。


如果它也重载了平等运算符(==在C#中)你也可以考虑使用它。

Mattias


-

Mattias Sj?gren [C#MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com

请回复到新闻组。

If the type overrides the Object.Equals method (and it should if it
supports value comparison), you can call that.

If it also overloads the equality operator (== in C#) you can also
consider using that.
Mattias

--
Mattias Sj?gren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


这篇关于如何检查wo对象是否相等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆