I saw this code:
this.CreateGraphics().DrawRectangle( Pens.Black, new Rectangle( 0, 0, 200, 100 ) );
CreateGraphics() is a method, but it acts like a class with static voids. How can I create this in my code? I don’t know how this technique can be called…
This is called Factory Method (it’s one of design patterns). Basically you create a method which will return new instances of class e.g.:
UPDATE
You can use this design patter in other places, all you need to do is to create a method which will return new instance of class (
CreateGraphicsmethod):