473,320 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Color.Equals seems totally useless

I guess this must be a well-known issue that I just hit my head on.

Color.Equals doesn't apply the usual equality test.

For example:

using (g = Graphics.FromImage(bmp))
g.FillRectangle(Brushes.Black, new Rectangle(Point.Empty, bmp.Size));

One might expect that for any (x, y) inside the image bounds,

bmp.GetPixel(x, y) == Color.Black

But it's not.

GetPixel returns an unnamed black color, while Color.Black returns a named
black color, and while the value is the same (0xff000000) they compare
unequal!

Anyone know a valid reason for this insanity before I post a bug on Connect?
Feb 18 '08 #1
2 1595
Jon Skeet [C# MVP] wrote:
>
Another concrete example:

string x = "mail";
string y = "MAIL";
bool b = (x.ToUpper() == y);

What's the value of b? I suspect if you ask 1000 C# developers, almost
all of them would say "true". Very few of them would say "It depends
whether or not the current culture is Turkish" which is the correct
answer.
As one of the 1000, may I ask what x.ToUpper() is when the current culture is
Turkish? :)
Feb 19 '08 #2
On Feb 19, 9:23 am, "Steve Gerrard" <mynameh...@comcast.netwrote:
Another concrete example:
string x = "mail";
string y = "MAIL";
bool b = (x.ToUpper() == y);
What's the value of b? I suspect if you ask 1000 C# developers, almost
all of them would say "true". Very few of them would say "It depends
whether or not the current culture is Turkish" which is the correct
answer.

As one of the 1000, may I ask what x.ToUpper() is when the current culture is
Turkish? :)
The I has an accent on it. Lower-casing has the same effect (so
y.ToLower()==x wouldn't help). I first ran into this in Java, with
exactly "mail" - I was trying to compare headers.

It's a particularly nasty bit of i18n.

Jon
Feb 19 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Arno Huetter | last post by:
Hi there, I try to execute a DB-Update using ADO.NET CommandBuilder (MSORA Data Provider) on Oracle 8.1.6 (unfortunately, ODP.NET seems to require Oracle 9i or above). One of ADO.NET's...
4
by: MLH | last post by:
In the late-70'ies, I was managing a biomechanical RDBMS. The mechanical part of it consisted of a 5-drawer Allsteel filing cabinet in the front office with customer file folders in it. The bio...
36
by: AussieRules | last post by:
Hi, I want to use the user color scheme to set the color of my forms. I now I have to use the. System.Drawing.SystemColors, but which color is the color of a form background as used in other...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
5
by: taumuon | last post by:
I've got an object, Person, that supports IEquatable<Person>. It implements bool Equals(Person obj) as well as overriding bool Equals(object obj) I've got a container type that holds a member...
1
by: sachy | last post by:
Hi, I have to find an object of Employee (Say 'Empl') in a list of objects of Employees (EmployeeList). The object Empl inturn has a list of objects (say List of Children objects ) in it. I have...
10
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that...
7
by: =?Utf-8?B?QWxleCBDb2hu?= | last post by:
In C++, there is an easy technique to provide an overloaded Equals() method. A straightforward translation to C# causes a stack overflow. Why does b.Equals(ba) in the snippet below not understand...
2
by: mjrtom19 | last post by:
I have a Jframe using a menubar to determine the color and shape of a graphics2d object, at the moment the color stays red no matter what. I think the problem is in the itemListener in the inner...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.