So i bumped in to this:
Public Stam {
public Stam() {Console.WriteLine("Stam");}
~Stam(){Console.WriteLine("Stam")}
}
What exactly is the ~? and what will happen when i call the Stam class.
So i bumped in to this:
Public Stam {
public Stam() {Console.WriteLine("Stam");}
~Stam(){Console.WriteLine("Stam")}
}
What exactly is the ~? and what will happen when i call the Stam class.
The ~ operator, in this circumstance, is being used to denote the class destructor, destructors are called automatically as part of the cleanup process.
However, the ~
can also be used for bitwise complement operation.
It is a destructor for the class. It is called automatically when an instance of the class is deleted, you use it to delete objects etc.
In C# it's called Destructor, the equivalent to a C++ destructor is IDisposable
and the Dispose()
method, often used in a using block.
See System.IDisposable from MSDN
What you are calling a destructor is better known as a Finalizer.
generally destructor function/methods are declared like this.
Your call seems like a finalizer.