Click here to Skip to main content
15,885,868 members
Articles / Programming Languages / C#

Static constructor in C#

Rate me:
Please Sign up or sign in to vote.
3.89/5 (6 votes)
25 May 2010CPOL1 min read 48.5K   11  
When you work with static class variables, the static constructor allows you to create much cleaner code. It gives you the ability to execute code before one of the static methods of the class is executed. You are able to initialize the static variables of your class with no lock or if statement.

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

No alternatives have been posted.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions