Home > Backend Development > C#.Net Tutorial > What is a finalizer in C#?

What is a finalizer in C#?

WBOY
Release: 2023-08-25 15:53:08
forward
1223 people have browsed it

C# 中的终结器是什么?

Finalizer in C# is used to destruct instances of a class. This way you can also use it to free up resources.

Here are some important points about finalizers -

  • Only one finalizer class is allowed
  • Cannot inherit or overload finalizers
  • The finalizer cannot have parameters
  • The finalizer automatically calls

The declaration method of the finalizer in C# is similar to the destructor. Assume the class name is Demo, therefore, the following will be our finalizer -

~Demo() {
   //
}
Copy after login

The finalizer declaration is prefixed with a tilde before the class name.

The above is the detailed content of What is a finalizer in C#?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template