C# Programming - Constructors - Discussion

Discussion Forum : Constructors - General Questions (Q.No. 10)
10.
How many times can a constructor be called during lifetime of the object?
As many times as we call it.
Only once.
Depends upon a Project Setting made in Visual Studio.NET.
Any number of times before the object gets garbage collected.
Any number of times before the object is deleted.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
8 comments Page 1 of 1.

John said:   1 decade ago
Only once because Whenever a class or struct is created, its constructor is called.

Ramesh Malode said:   1 decade ago
When you create the object of the class default constructor called automatically.

Rahul singh said:   1 decade ago
Suppose we call parameterized constructor then we call constructor depend upon the object , how many time object are created that time constructors are called.

Ex:-

cons c = new cons(34,23)
cons d = new cons(24,45)

Here we call parameterized constructor two times..

Faizan Sarwar said:   1 decade ago
During the lifetime of any object whether it is parameterized or non- parameterized the constructor is called only once.

Deepak Mishra said:   9 years ago
Constructor will call n times if we create the instance of the class & times.

Creation of instance is nothing but calling of the constructor. Please verify it.

Deepak Mishra said:   9 years ago
We are talking about which constructor, Static constructor or instance constructor? Because both have different nature in order to call.

Sidharth said:   7 years ago
@RAHUL SINGH.

There you have declared two object of same class. For each object constructor can be called once only.

Nikesh Rathour said:   6 years ago
The static constructor can be called only once in its lifetime whereas non-static constructor or explicit can be called n times if n object is created.

Post your comments here:

Your comments will be displayed after verification.