
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Call a Static Constructor in C#
Static constructor are called automatically before the first instance is created or any static members are referenced.
A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed once only.
In c#, only one static constructor is allowed to create
Static constructors have the following properties −
A static constructor does not take access modifiers or have parameters.
A class or struct can only have one static constructor.
Static constructors cannot be inherited or overloaded.
A static constructor cannot be called directly and is only meant to be called by the common language runtime (CLR). It is invoked automatically.
The user has no control on when the static constructor is executed in the program.
Example
class Program{ static Program(){ // Your Code } static void Main(){ Console.ReadLine(); } }