2

Question: What does this mean and for what use would one implement this:

public class Parameter : Variable
{
    public Parameter(NDArrayView value);

    ~Parameter();

    public override void Dispose();
}

Of course, the question is specifically targeting this Method Constructor:

~Parameter();

Thank you.

Rusty Nail
  • 2,692
  • 3
  • 34
  • 55
  • 4
    It is a finalizer. What use is it? In practical terms, none at all. It is incredibly rare to need to write a finalizer in 2019. – mjwills Jul 26 '19 at 11:04
  • 4
    See [Finalizers (C# Programming Guide)](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/destructors) – Georg Patscheider Jul 26 '19 at 11:04

2 Answers2

1

The ~ used in above code serves purpose of destructor. Like how constructor is used to initialize some values or object, destructor is used for exactly opposite purpose. It has same name as class like constructor, but it starts with ~ operator.

Abhishek
  • 80
  • 6
0

The ~ symbol can be use for :

1/. Finaliser declaration:

class Car
{
    ~Car()  // finalizer
    {
        // cleanup statements...
    }
}

2/. Bitwise complement operator, produces a bitwise complement of its operand by reversing each bit.

xdtTransform
  • 1,986
  • 14
  • 34