Equality of GDI+ Regions
问题 Why does the assertion fail in the following code? Why aren't regions a and b equal? Region a = new Region(new RectangleF(0.0f, 0.0f, 10.0f, 10.0f)); Region b = new Region(); b.MakeEmpty(); b.Union(new RectangleF(0.0f, 0.0f, 10.0f, 10.0f)); Debug.Assert(a == b, "Regions not equal"); 回答1: From what I can see, System.Drawing.Region does not override Object 's implementation of Equals() . Therefore your == call is using ReferenceEquals and simply telling you a and b are not the same object. Try