5
Reply

What is a static constructor in C#?

Kunal  Gautam

Kunal Gautam

11y
1.4k
0
Reply

    1) A class can have one and only one Static Constructor. 2) The Static Constructor should not have any access modifier. 3) Static Constructors should not have any parameters. 4) The Static constructor will be executed only one time irrespective of number of objects created 5) Runtime invokes the Static Constructor when it creates an instance of the class or before the first static member being accessed. 6) The Static Constructor executes before any of the instance level constructors.

    constructor are only default ,parameterised and copy i didn't ever listen static constructor ... but static word can use with constructors ... like public sara() { Console.writeLine(" its non static and have an extra place in heap"); } static public sara() { console.writeLine("its static,and the value place on the same place no extra space here use it "); }

    constructor are only default ,parameterised and copy i didn't ever listen static constructor ... but static word can use with constructors ... like public sara() { Console.writeLine(" its non static and have an extra place in heap"); } static public sara() { console.writeLine("its static,and the value place on the same place no extra space here use it "); }

    A constructor that is declared using static modifier is a static constructor. Static constructor executes one and only one time in the life cycle of class. It is the first block of code to execute in class. A static constructor can not be parametrized.

    A constructor that is declared using static modifier is a static constructor. Static constructor executes one and only one time in the life cycle of class. It is the first block of code to execute in class. A static constructor can not be parametrized.