V
V
Vladislav2020-07-13 14:12:49
C++ / C#
Vladislav, 2020-07-13 14:12:49

How to call a destructor?

Here is the code, how do I call the destructor?

class Program
    {
        static void Main(string[] args)
        {
            Program f = new Program();
        }

        public Program()
        {
            Console.WriteLine("Конструктор");
        }

        ~Program()
        {
            Console.WriteLine("Деструктор");
        }
        
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
ayazer, 2020-07-13
@Vladlen234

no need to manually call the destructor, it will be called when the GC releases resources.

V
Vladimir Korotenko, 2020-07-13
@firedragon

Implement IDisposable. Well, or pull GC.Collect()
https://docs.microsoft.com/ru-ru/dotnet/api/system...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question