Introduction
In this article, you will learn about the difference between Constructors and Destructors in C#.
Below is an overview of this article:
- Background
- Difference between Constructors and Destructors in C#
- Practical Scenarios
- Summary
Background
Here is a list of the key differences between Constructors and Destructors in C#. This article will be useful to both beginners and professional C# developers.

Difference between Constructors and Destructors in C#
| Category | Constructor | Destructor |
| What is the use of Constructors & Destructors? | Constructors are used when instantiating a class. | Destructors are used to clean up resources used by the object. |
| What are Constructors & Destructors? | The constructor is a special method of the class that is called when a class is instantiated. | Destructor is opposite of constructor. It is a special method of the class that is invoked when a class object goes out of scope. |
| Name of Constructor & Destructor? |
Constructor name is same as class name.
~<ClassName>
|
Destructor name is same as class name with starting ~.
~<ClassName>
|
| Access Modifiers? |
Constructor can have access modifiers.
By default it is public.
|
Destructor can’t have access modifiers. |
| Parameterized Constructor and Destructor? |
Constructor can have parameter(s). | Destructor can’t have parameter(s). |
| Types of Constructor and Destructor? |
Constructors can be divided into 5 types:
Default Constructor (Parameter Less Constructor), Parameterized Constructor, Copy Constructor, Static Constructor, Private Constructor
|
Destructor can’t have different types. |
| Number of Constructors and Destructors? |
Constructors can be multiple in a class. |
Destructors can’t be multiple in a class.
A Destructor is unique to its class.
|
| Constructors and Destructors defined in Structures? | Constructors can be defined in Structures. |
Destructors can’t be defined in Structures. |
| When are Constructors and Destructors invoked? |
Constructor gets automatically invoked whenever an instance of the class is created. |
Destructors are invoked automatically, and cannot be invoked explicitly.
Execution of the destructor for the instance may occur at any time after the instance becomes eligible for destruction.
|
Practical Scenarios
Example 1
How to create a Constructor and Destructor?
- class Member
- {
- public Member()
- {
- Console.WriteLine("Default Constructor was called.");
- }
- public Member(string name)
- {
- Console.WriteLine("Parameterized Constructor was called.");
- }
- ~Member()
- {
- Console.WriteLine("Destructor was called.");
- }
- }

Rushang VoraPosted Nov 14, 2022, 6:28 AM
Helpful Article
Panival BharatPosted Nov 18, 2020, 1:00 AM
Good Article