Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 2
    Because for classes it'll perform pointer comparison. For struct it's not defined (because it should do an expansive reflection comparison unless it has been defined by implementer). Think if the struct contains classes (it's possible). In that case how comparison should be done (just by reference? calling comparison operator for each class?). Think moreover if struct contains big data arrays (bad bad practice but it's allowed and under your responsability). What compiler should emit for that? For that reason IMO even a call to Equals() is pretty pretty inefficient. Commented Nov 15, 2013 at 15:46
  • 1
    possible duplicate of Comparing two structs using == Commented Nov 15, 2013 at 15:48
  • Why are you using a struct instead of a class anyways? (I'm not questioning your decision, just wondering if you've thought about it and understand the differences.) Commented Nov 15, 2013 at 15:49
  • @AdrianoRepetti: An array is a reference type. So, if the structs contain arrays, the == operator would just do a reference comparison on them. Commented Dec 15, 2017 at 16:52