Рет қаралды 20,785
In this video you will get information on Use of Constructor and Destructor.
This video will give you complete training in Use of Constructor and Destructor
For Complete C# Online Training Please visit:
www.bestdotnettraining.com/cs...
Use of Constructor and Destructor
Constructors are special methods, used when instantiating a class. A constructor can never return anything, which is why you don't have to define a return type for it. A normal method is defined like this:
In our example for this chapter, we have a Car class, with a constructor that takes a string as an argument. Of course, a constructor can be overloaded as well, meaning we can have several constructors, with the same name, but different parameters. Here is an example
Destructors
Since C# is garbage collected, meaning that the framework will free the objects that you no longer use, there may be times where you need to do some manual cleanup. A destructor, a method called once an object is disposed of, can be used to clean up resources used by the object. Destructors don't look very much like other methods in C#. Here is an example of a destructor for our Car class
________________________________________________________________________________________________
This video was compiled by Mr. Sandeep Soni, a Microsoft Certified Trainer and an Azure Solution Architect. Know more - www.bestdotnettraining.com/sa...
Mr. Sandeep Soni is a famous Corporate Trainer in Microsoft Azure AZ-103, AZ-203, AZ-300, AZ-301, AZ-400, AZ-500, Containerization in Docker, Microservices - Kubernetes and Azure Service Fabric and more...
For Corporate Training requests, please contact Mr. Soni @ +91 9849001840, or email him to sandeepsoni@deccansoft.com.
Or DM in LinkedIn - / sandeepsonimct
Please subscribe to our channel for more related videos: / deccansoft123
For any course-related queries, reach us @ +91 8555823343 / +91 8008327000 Kashmira Shah
Please leave your comment about the videos.
For more updates on courses and tips follow us on:
- Facebook: / deccansofthome
- Twitter: / deccansoft
- LinkedIn: / deccansoft-software-se...
- Website: www.deccansoft.com/ or www.bestdotnettraining.com/
- Join our WhatsApp group - chat.whatsapp.com/HzE43FXv0HJ...