Testing equality of Pen objects

  • Thread starter Thread starter Tristan
  • Start date Start date
T

Tristan

Hi,

I'm trying to test if two Pen objects are equal as shown below:

Pen p1 = new Pen(Color.Black);
Pen p2 = new Pen(Color.Black);

if (p1.Equals(p2))
{
Console.WriteLine("These pens equal");
}

The problem is that the if statement doesn't return true, I would have
thought that p1 and p2 are the same. Is the only way round this to
write my own function which compares every single property of Pen?
That would be very laborious and time consuming!

Help much appreciated.

Tristan.
 
Does the Pen object have a "ToString" perhaps comparing the string would be
enough?
 
I think, it doesn't work, the "ToString" will return the type, something like this "System.Drawing.Pen". I think he must try to put, for example, a name to the pen, and then compare by name, or somethin like that..

I hope this help...
 
Back
Top