Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  C语言  >  正文 Destructors in C

Destructors in C

发布时间:2019-01-11   编辑:www.jquerycn.cn
jquery中文网为您提供Destructors in C等资源,欢迎您收藏本站,我们将为您提供最新的Destructors in C资源
Destructors in C#
By Ansil
Introduction
In the enterprise application development world, the buzzwords are Performance, Scalability, and Security. I started my career as a VC programmer, and one fine morning, I was transferred to Web development department. Like every C programmer, I also was frustrated. I thought every Tom, Dick, and our very own Harry can program in HTML. But, soon I found that the real challenge is to produce high performance, scalable, and reliable applications. And above all that the loosely coupled, stateless nature of web environment is always going to haunt you.
In order to produce high performance scalable applications, it is important to use your resources in an optimized manner. One tip is that use your resource as late as you can and free it at the earliest after your use. My intention here is to describe the object cleaning up mechanism used in C#.
Destructors
As we all know, 'Destructors’ are used to destruct instances of classes. When we are using destructors in C#, we have to keep in mind the following things:
A class can only have one destructor.
Destructors cannot be inherited or overloaded.
Destructors cannot be called. They are invoked automatically.
A destructor does not take modifiers or have parameters.
The following is a declaration of a destructor for the class MyClass:~ MyClass()
{
// Cleaning up code goes here
}
The programmer has no control on when the destructor is going to be executed because this is determined by the Garbage Collector. The garbage collector checks for objects that are no longer being used by the application. It considers these objects eligible for destruction and reclaims their memory. Destructors are also called when the program exits. When a destructor executes what is happening behind the scenes is that the destructor implicitly calls the Object.Finalize method on the object's base class. Therefore, the preceding destructor code is implicitly translated to:protected override void Finalize()

您可能感兴趣的文章:
Destructors in C
C# FAQ for C programmers
幻灯片带网页设计中的20个奇妙应用示例小结
HOW TO: Set a Windows Hook in Visual C# .NET-Windo
IOCP Thread Pooling in C
批处理删除大小和类型一样的文件
C# Programming Guidelines
JavaScript基本运动封装函数(1)
python 全局变量怎么改
源码安装的bind9.9启动后提示没有权限的解决方法

[关闭]