1
Vote

Rectangle.Inflate Extension Method is Useless

description

The Inflate extension method on the Rectangle is useless. It is supposed to modify the Rectangle it is called on, but since that Rectangle is passed by value into the extension method, the original Rectangle never gets modified.
 
If you run this snippet of code, you will see that "rect" never gets modified by the call to Inflate.
 
Rectangle rect = new Rectangle(10, 10, 80, 80);
rect.Inflate(10, 10);
 
My suggestion would be to remove the method, because I don't believe there is a way to pass by reference using an extension method.

comments