IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
KB
   ► KB ► > Finalizer Posts  Print This     

Finalizer Posts

"Finalizer" Knowledge Base Posts

More...
  KB Article    

Mike Prestwood
1. Delphi Prism Finalizer (finalize())

Unlike Delphi, Delphi Prism uses the .Net garbage collector to free managed object instances. Prism does not have nor need a true destructor.

In .Net, a finalizer is used to free non-managed objects such as a file or network resource. Because you don't know when the garbage collector will call your finalizer, Microsoft recommends you implement the IDisposable interface for non-managed resources and call it's Dispose() method at the appropriate time.

Posted to KB Topic: OOP
12 years ago, and updated 12 years ago

Code

Article
Nothing New Since Your Last Visit  
21105
Hits

Delphi Prism

Mike Prestwood
2. C# Constructors (Use class name)

In C#, a constructor is called whenever a class or struct is created. A constructor is a method with the same name as the class with no return value and you can overload the constructor. If you do not create a constructor, C# will create an implicit constructor that initializes all member fields to their default values.

Constructors can execute at two different times. Static constructors are executed by the CLR before any objects are instantiated. Regular constructors are executed when you create an object.

Posted to KB Topic: OOP
12 years ago, and updated 12 years ago

Code

Article
Nothing New Since Your Last Visit  
17767
Hits

C# (Visual C# & VS.Net)

Mike Prestwood
3. VB.Net Finalizer (Finalize())

Use a destructor to free unmanaged resources. A destructor is a method with the same name as the class but preceded with a tilde (as in ~ClassName). The destructor implicity creates an Object.Finalize method (you cannot directly call nor override the Object.Finalize method).

In VB.Net you cannot explicitly destroy an object. Instead, the .Net Frameworks garbage collector (GC) takes care of destroying all objects. The GC destroys the objects only when necessary. Some situations of necessity are when memory is exhausted or you explicitly call the System.GC.Collect method. In general, you never need to call  System.GC.Collect.

Posted to KB Topic: OOP
12 years ago, and updated 12 years ago
(3 Comments , last by marcus.t )

Code

Article
Nothing New Since Your Last Visit  
21306
Hits

VB.Net Language

Mike Prestwood
4. Class Destructor

A special class method called when an object instance of a class is destroyed. With some languages they are called when the object instance goes out of scope, with some languages you specifically have to call the destructor in code to destroy the object, and others use a garbage collector to dispose of object instances at specific times.

Desctructors are commonly used to free the object instance but with languages that have a garbage collector object instances are disposed of when appropriate. Either way, destructors or their equivalent are commonly used to free up resources allocated in the class constructor.

Posted to KB Topic: Object Orientation (OO)
12 years ago, and updated 12 years ago

Definition
Nothing New Since Your Last Visit
18584
Hits

Coding & OO

Mike Prestwood
5. C++/CLI Finalizer (~ClassName)

Unlike standard C++, C++/CLI uses the .Net garbage collector to free managed object instances. Prism does not have nor need a true destructor.

In .Net, a finalizer is used to free non-managed objects such as a file or network resource. Because you don't know when the garbage collector will call your finalizer, Microsoft recommends you implement the IDisposable interface for non-managed resources and call it's Dispose() method at the appropriate time.

Posted to KB Topic: C++/CLI OOP
12 years ago

Code
Nothing New Since Your Last Visit
10731
Hits

C++
More...


Icon Legend:
Since your last logged visit:
- New to you or updated since your last visit (sign in now to activate).
- NOT new to you since your last visit (sign in now to activate).
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2021 Prestwood IT Solutions.   [Security & Privacy]