Re: Extending System.Drawing.Rectangle...

"Hewitt, Simon C. (Contractor)" <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <CF362B9DFA7D2544934516DFA1459AEC0147F5A7@BP1XEUEX709-C.bp1.ad.bp.com>
The problem would be of course that existing classes that accept a
Rectangle wouldn't work with your new class.

Since you don't mention adding new fields, just new members/function, I
assume you want to add methods to manipulate existing data? 

That being the case, how about creating a class called RectangleHelper
which has static methods that manipulate a passed in rectangle? It would
be fully under your control and no problem with interaction with
existing framework classes.

Cheers
Simon
 

> -----Original Message-----
> From: Discussion forum for developers using Windows Forms to 
> build apps and controls 
> [mailto:[email protected]] On Behalf Of 
> Gyorgy Bozoki
> Sent: 18 April 2007 05:24
> To: [email protected]
> Subject: [DOTNET-WINFORMS] Extending System.Drawing.Rectangle...
> 
> Hi all,
> 
> I have a question about extending structs: I'd like extend
> System.Drawing.Rectangle such that it keeps all its existing 
> functionality
> and a set of new public members can be called. Since Rectangle is a
> structure, it's sealed and cannot be derived from, so that route is
> obviously out.
> 
> I could easily create a simple new class that would have all the
> functionality of Rectangle and the extra functions that I 
> want to add, but I
> was wondering if doing this to Rectangle itself would even be 
> technically
> possible (for example during run time, if necessary.)
> 
> Thanks,
> Gyorgy Bozoki
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.