Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding static components via the IDE? 1

Status
Not open for further replies.

keyser456

IS-IT--Management
Nov 21, 2003
73
US
You know how as you add components to a form or control the IDE automatically updates the InitializeComponent() method of your code. Is there any way to get the IDE to add static components to a form or control? Maybe it would add a static constructor and create a static method called InitializeStaticComponent()? As you changed the properties of this component it would do the updating necessary in that section as well.

Is this possible? If not, do you think it might be a good feature?
 
I think there is no way to that with IDE.
You should avoid static members as much you can.
A static constructor cannot be called directly.
A static constructor for a class executes at most once in an application e.g. when an instance of that class is created and when any of the static method of the class is referenced!
So, there is no control on when the static constructor is executed in the program.
A typical scenario to use a static constructors is when the class implements a log file and then the constructor is used to log entries to this file.
-obislavu-
 
Thanks obislavu. I suppose I will have to find another method to accomplish my goal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top