473,802 Members | 2,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.FromIm age(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 1611
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...@com cast.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
2901
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 DataTable columns is of type Byte-Array, and refers to a RAW column on the Oracle-DB. The CommandBuilder generates Update-Statements of this kind:
4
1234
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 part of it consisted of 3 sales gjuys and the secretary in the front office. I claim it was fully relational. I established an office procedure whereby the sales guys (who were pretty much uncontrollable) could take orders on anything - back of a...
36
2488
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 applications. In the end all I want to do is form1.backcolor = system.whatever.color
18
4752
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 class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
5
2393
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 object of generic type T, that supports IEquatable<T>, and a method, DoComparisons(T obj) to compare the member object to the object passed in.
1
6836
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 used Find method with predicate as follows, Class Employee { string name; List<Childrenchildrens; //Assume getters and setters
10
105209
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 make use of these methods assume that the methods obey these contracts so it is necessary to ensure that if your classes override these methods, they do so correctly. In this article I'll take a look at the equals and hashCode methods. ...
7
2670
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 that it should call (ba as B).Equals(b) inside? Thanks in advance, Alex code sample follows:
2
7476
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 class myShape, but I dont know what it is. Heres the code: import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.awt.Graphics2D.*; import java.awt.geom.*;
0
10532
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10281
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10058
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9111
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6835
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.