SlideShare a Scribd company logo
C# Tutorial
Part 26:Destructor
www.siri-kt.blogspot.com
• A destructor works opposite to constructor, It destructs
the objects of classes. It can be defined only once in a class.
Like constructors, it is invoked automatically.
• Destructor is used deal locate the memory. it used to
closing the connections, closing the files. class name and
destructor name is the same but prefixed with ~(tilled) one
class supports only one destructor.
• Destructor is deallocate the memory. once we close the
application memory is deallocating. this concept based
garbage class. oops is nothing object oriented programming
system. we can gathered classes, properties, methods &
events
• Note: C# destructor cannot have parameters. Moreover,
modifiers can't be applied on destructors.
• C# Constructor and Destructor Example
• using System;
• public class Employee
• { public Employee()
• { Console.WriteLine("Constructor Invoked"); }
• ~Employee()
• { Console.WriteLine("Destructor Invoked"); } }
• class TestEmployee{
• public static void Main(string[] args)
• { Employee e1 = new Employee();
• Employee e2 = new Employee();
• } }
• Output:
• Constructor Invoked Constructor Invoked Destructor Invoked Destructor
Invoked
• Note: Destructor can't be public. We can't apply any modifier on
For more visit our website www.siri-kt.blogspot.com
Thanks for
Watching
More Angular JS TutorialsMore C sharp (c#) tutorials

More Related Content

What's hot

constructor and destructor
constructor and destructorconstructor and destructor
constructor and destructor
VENNILAV6
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop
Samad Qazi
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
Saharsh Anand
 
Lesson6
Lesson6Lesson6
Designpatterns illustrated
Designpatterns illustratedDesignpatterns illustrated
Designpatterns illustrated
Nhat Vo Van
 
C# Constructors
C# ConstructorsC# Constructors
C# Constructors
Prem Kumar Badri
 
Destructors
DestructorsDestructors
Destructors
DeepikaT13
 
Type script
Type scriptType script
Type script
Zunair Shoes
 
Constructor and Destructor PPT
Constructor and Destructor PPTConstructor and Destructor PPT
Constructor and Destructor PPT
Shubham Mondal
 

What's hot (9)

constructor and destructor
constructor and destructorconstructor and destructor
constructor and destructor
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop
 
Constructor & destructor
Constructor & destructorConstructor & destructor
Constructor & destructor
 
Lesson6
Lesson6Lesson6
Lesson6
 
Designpatterns illustrated
Designpatterns illustratedDesignpatterns illustrated
Designpatterns illustrated
 
C# Constructors
C# ConstructorsC# Constructors
C# Constructors
 
Destructors
DestructorsDestructors
Destructors
 
Type script
Type scriptType script
Type script
 
Constructor and Destructor PPT
Constructor and Destructor PPTConstructor and Destructor PPT
Constructor and Destructor PPT
 

Similar to 26csharp

C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
murugeswariSenthilku
 
Constructor destructor.ppt
Constructor destructor.pptConstructor destructor.ppt
Constructor destructor.ppt
Karthik Sekar
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
Prof. Dr. K. Adisesha
 
Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++
aleenaguen
 
C++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptxC++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptx
sasukeman
 
Object-oriented programming 3.pptx
Object-oriented programming 3.pptxObject-oriented programming 3.pptx
Object-oriented programming 3.pptx
Adikhan27
 
What is Constructors and Destructors in C++ (Explained with Example along wi...
What is Constructors and Destructors in  C++ (Explained with Example along wi...What is Constructors and Destructors in  C++ (Explained with Example along wi...
What is Constructors and Destructors in C++ (Explained with Example along wi...
Pallavi Seth
 
Learning C++ - Class 4
Learning C++ - Class 4Learning C++ - Class 4
Learning C++ - Class 4
Ali Aminian
 
Oops
OopsOops
Destructors
DestructorsDestructors
Destructors
Mirza Hussain
 
Constructor and destructor in C++
Constructor and destructor in C++Constructor and destructor in C++
Constructor and destructor in C++
Lovely Professional University
 
Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2
Lovely Professional University
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
RatnaJava
 
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & PrototypesIntro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Blue Elephant Consulting
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
Michael Heron
 
Destructer
DestructerDestructer
Destructer
Jay Prajapati
 
C# structure
C# structureC# structure
C# structure
ElangovanTechNotesET
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
MH Abid
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++
RAJ KUMAR
 

Similar to 26csharp (20)

C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Constructor destructor.ppt
Constructor destructor.pptConstructor destructor.ppt
Constructor destructor.ppt
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++
 
C++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptxC++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptx
 
Object-oriented programming 3.pptx
Object-oriented programming 3.pptxObject-oriented programming 3.pptx
Object-oriented programming 3.pptx
 
What is Constructors and Destructors in C++ (Explained with Example along wi...
What is Constructors and Destructors in  C++ (Explained with Example along wi...What is Constructors and Destructors in  C++ (Explained with Example along wi...
What is Constructors and Destructors in C++ (Explained with Example along wi...
 
Learning C++ - Class 4
Learning C++ - Class 4Learning C++ - Class 4
Learning C++ - Class 4
 
Oops
OopsOops
Oops
 
Destructors
DestructorsDestructors
Destructors
 
Constructor and destructor in C++
Constructor and destructor in C++Constructor and destructor in C++
Constructor and destructor in C++
 
Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2Constructors and destructors in C++ part 2
Constructors and destructors in C++ part 2
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & PrototypesIntro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
 
2CPP04 - Objects and Classes
2CPP04 - Objects and Classes2CPP04 - Objects and Classes
2CPP04 - Objects and Classes
 
Destructer
DestructerDestructer
Destructer
 
C# structure
C# structureC# structure
C# structure
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Constructors and destructors in C++
Constructors and destructors in  C++Constructors and destructors in  C++
Constructors and destructors in C++
 

More from Sireesh K

Cn10
Cn10Cn10
Cn10
Sireesh K
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
Sireesh K
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
Sireesh K
 
What is mvc
What is mvcWhat is mvc
What is mvc
Sireesh K
 
31c
31c31c
31cs
31cs31cs
31cs
Sireesh K
 
45c
45c45c
44c
44c44c
43c
43c43c
42c
42c42c
41c
41c41c
40c
40c40c
39c
39c39c
38c
38c38c
37c
37c37c
35c
35c35c
34c
34c34c
33c
33c33c
30c
30c30c
29c
29c29c

More from Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
31cs
31cs31cs
31cs
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 

Recently uploaded

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 

Recently uploaded (20)

Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 

26csharp

  • 2. • A destructor works opposite to constructor, It destructs the objects of classes. It can be defined only once in a class. Like constructors, it is invoked automatically. • Destructor is used deal locate the memory. it used to closing the connections, closing the files. class name and destructor name is the same but prefixed with ~(tilled) one class supports only one destructor. • Destructor is deallocate the memory. once we close the application memory is deallocating. this concept based garbage class. oops is nothing object oriented programming system. we can gathered classes, properties, methods & events • Note: C# destructor cannot have parameters. Moreover, modifiers can't be applied on destructors. • C# Constructor and Destructor Example
  • 3. • using System; • public class Employee • { public Employee() • { Console.WriteLine("Constructor Invoked"); } • ~Employee() • { Console.WriteLine("Destructor Invoked"); } } • class TestEmployee{ • public static void Main(string[] args) • { Employee e1 = new Employee(); • Employee e2 = new Employee(); • } } • Output: • Constructor Invoked Constructor Invoked Destructor Invoked Destructor Invoked • Note: Destructor can't be public. We can't apply any modifier on
  • 4. For more visit our website www.siri-kt.blogspot.com Thanks for Watching More Angular JS TutorialsMore C sharp (c#) tutorials