Re: Comparing Empty Value types

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 11/17/04


Date: Wed, 17 Nov 2004 11:10:35 -0600

Cor (& others),
> however I like more evaluating for equality using the = operator than
So do I, however I want to be certain I know what I am actually comparing &
what I am "slicing" off.

If I use Color.ToArgb to compare the colors I loose comparing the names of
the colors.

Further! As I stated last night in VB.NET 2005 you can use the = operator to
compare colors, it will give you the same result as Color.Equals &
Color.op_Equality, not Color.ToArgb.

So if you want your code to be consistent from VB.NET 2002 to VB.NET 2005
what each method actually does is something to be aware of.

I do find it kind of odd that Color does not have a shared Color.Compare
method, but it has an overloaded = operator.

Hope this helps
Jay

"Cor Ligthert" <notmyfirstname@planet.nl> wrote in message
news:%23IeiyJMzEHA.2624@TK2MSFTNGP11.phx.gbl...
> Jay,
>
> It was just an alternative, this one is not real very important for me,
> however I like more evaluating for equality using the = operator than
> evaluating using a methode and with the color that is possible.
>
> But the "Is" in this functions tells it very good, therefore it is not
> really that important for me.
>
> However as I said, just an alternative.
>
> Cor
>
> "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@msn.com>
>
>> Cor (& Herfried),
>> As I stated in my initial reply:
>>
>>> See the Color.Equals function in the online help for some important
>>> remarks about using Color.Equals and when you may want to use
>>> Color.ToArgb to compare two colors.
>>
>> If I want to compare what is visible seen I will use Color.ToArgb in
>> other words to compare the Alpha, Red, Green & Blue values.
>>
>> If I want to compare what is literally used I will use Color.Equals or
>> Color.op_Equality, in other words to compare the names of the color or
>> the values for unnamed colors.
>>
>> For example:
>>
>> Dim color1 As Color = Color.Black
>> Dim color2 As Color = Color.FromArgb(0,0,0)
>>
>> Both are visibly Black, however they are not logically the same value. In
>> other words:
>>
>> If color1.Equals(color2) Then
>> ' color1 is the same named color as color2
>> End If
>>
>> If color1.ToArgb() = color2.ToArgb() Then
>> ' color1 & color2 have the same Alpha, Red, Green & Blue values
>> End If
>>
>> Just a thought
>> Jay
>>
>>
>> "Cor Ligthert" <notmyfirstname@planet.nl> wrote in message
>> news:ulhANFIzEHA.2568@TK2MSFTNGP11.phx.gbl...
>>> Dennis,
>>>
>>> As alternative
>>> If mycolor.ToArgb = mycolor.Empty.ToArgb
>>>
>>> End if
>>>
>>> Cor
>>>
>>> "Dennis" <Dennis@discussions.microsoft.com>:
>>>>
>>>> public mycolor as color = color.Empty
>>>>
>>>> I want to check to see if the user has specified a color like;
>>>>
>>>> if mycolor = Color.Empty then.....
>>>> or
>>>> if mycolor is Color.Empty then .......
>>>>
>>>> I get errors saying that = can be used for colors and is can't be used
>>>> with
>>>> value types. I give up...how do I do this. Thanks.
>>>> --
>>>> Dennis in Houston
>>>
>>>
>>
>>
>
>



Relevant Pages

  • Re: Comparing Empty Value types
    ... however I like more evaluating for equality using the = operator than ... evaluating using a methode and with the color that is possible. ... Cor ... >> Color.ToArgb to compare two colors. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: collection framework: using the good interface
    ... The word object's class would implement Comparable, and should have equals and hashCode consistent with compareTo, but I would not make two words equal unless they are, in all respects, the same word. ... I'm more and more convinced that equality should involve all aspects of the Word class, but I'm still uncomfortable with mixing lexicographic information (allowing to compare objects in different collections) and information about frequency, distribution, cooccurrents. ...
    (comp.lang.java.help)
  • Re: If statement
    ... i want to compare atabsin equality ... or call the function atabs passing in the argument i ... since that value is *not* non-zero, ...
    (comp.soft-sys.matlab)
  • Re: [CLOS] Ensuring a method exists
    ... application wants to compare. ... I said "depending on context" for a reason: I think something like dynamically scoped functions or ContextL can be of use here. ... The equality operators in CL are generic in the sense that they are ...
    (comp.lang.lisp)
  • Re: Glasgow haskell vs. Lispworks
    ... 'dbenson AT eecs DOT wsu DOT edu' wrote: ... Jon simply has been using the object identity instead of value ... The equality on objects is said to be object ... This is useful to compare ...
    (comp.lang.functional)