Join Gerry O'Brien for an in-depth discussion in this video Using destructors, part of Learning C#.
As we work with objects in our C# applications in the .NET framework, we…generate class files to form the definition…of the objects we'll use in our code.…When we instantiate an object, we use a constructor to build the object, or to…initialize instance variables, setting values for any of…the member variables that may exist within it.…We also have the opportunity to create something called…the destructor, which is used to tear down our object.…So, destructor is the opposite of a constructor.…We use a constructor to build our object in code or…to apply values to the instances of the objects that we…create within our code, and we use a destructor to tear…down or to destroy the object when we're finished with it.…Destructors cannot be used with structs.…So although structs in classes are similar in C# within the .Net framework, only…classes actually use destructors because classes are…reference types, and structs are value types.…Each class can have only one destructo, so you're not…going to have multiple destructors existing within a single class.…
- Installing C#
- Working with loops
- Controlling program flow
- Using variables
- Building functions
- Creating and instantiating classes
- Catching errors
- Managing resources with the garbage collector
- Building collections
Skill Level Beginner
1. Introducing C#
2. C# Language Elements
3. Object-Oriented Programming in C#
4. Structured Exception Handling
5. Resource Management in C#
6. Extensible Types in C#
7. Windows Apps in C#
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.