My question is why we use delete operators for our objects?
Does not .net supply it for us?
Additionally, I write a small program with two buttons. In the first button I created an object and in the second button I delete it. I Look over the windows process explorer while the program is running, but when I clicked the second button the memory did not decrease. I did not understand the process?
The delete operator in C++/CLI doesn’t do the same thing as the operator in C++. Indeed, memory is managed by the garbage collector, you cannot release it explicitly. But objects can use additional resources beyond memory, most typically they are operating system handles or pointers to unmanaged heap memory. The garbage collector will release those too but that takes time. If the resource is expensive you’ll want to release it when you have no use for it anymore instead of waiting for the finalizer to take care of it. This is called disposing in .NET.
Using delete on a button object has an immediate result, the button disappears. The window for the button control is one of those operating system resources. This will in general not reduce the memory usage. The handle count goes down.