Re: op_Equality (== Operator) for Value-Types

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Tue, 20 Mar 2007 16:39:17 +0530, "MasterGaurav
\(www.edujini-labs.com\)" <gaurav.vaish.nospam@xxxxxxxxxxxxxxxx>
wrote:

Why cannot I use the == operator directly for value-types (not primitive
types like int, float, double etc)? Why do I need to either have an implicit
operator (to type-cast to primitive type) or override/overlaod the ==
operator myself?

I'm assuming what you want is a default definition of operator== for
value types that does a bitwise comparison of all member variables.

I agree that would have been convenient since it's normally exactly
what you want. No idea why the .NET team didn't do that. They might
have judged it not worth the effort since user-defined value types are
(or should be) rare.
--
http://www.kynosarges.de
.



Relevant Pages

  • Re: Multiplying sequences with floats
    ... There could be either an implicit typecast to ... Explicit is better than implicit. ... Anyway this would be an argument only against the variant of typecasting a float with a fractional part. ... the multiplication of a sequence with an int does an even more implicit thing: The number is considered to be zero if it is negative. ...
    (comp.lang.python)
  • Re: Abnormal program termination
    ... foo.c:4: warning: function declaration isn't a prototype ... Your version is legal under C90 rules, but int mainis more explicit ... float ave(), average; ...
    (comp.lang.c)
  • RTF Render with Scale
    ... float fHorzSizeInches = nHorzSize / 25.4f; ... IntPtr hdc = graphics.GetHdc; ... int nHorzSize = SafeNativeMethods.GetDeviceCaps(hdc, ... PHYSICALWIDTH = 110, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: RAD vs. performance
    ... work with both int and float. ... name (e.g. "+" for both int and float addition). ... Again, it's a compatibility issue. ... contend that assuming interfaces are equivalent and inferring the most ...
    (comp.lang.misc)
  • (part1b) Han from China teaches you C
    ... int flist, mlist, slist; ... float board_size; ... static void draw_tube(float bottom_radius, float top_radius, ... glVertex3f(xmin, ymin, zmax); glVertex3f; ...
    (comp.lang.c)