What is a Destructor? - C# Gotcha Interview Questions

Опубликовано: 16 Октябрь 2024
на канале: Ryan McBeth
4,955
235

That the heck is that method that has the same name as the class and has a ~ at the beginning.

It's a destructor, and there's a reason why you haven't seen it before. Modern languages need a destructor, but the problem is that if you rely on the destructor to release physical or unmanaged resources, you may be in for a surprise.

If a company is asking about destructors during a job interview, it may be a sign that they are using a very old version of the .NET framework or that they just printed out random interview questions from the internet without knowing exactly what they are.

Either way its a bad sign and my may want to skip that job.