8.7.9 Destructors
来源:互联网 发布:马拉多纳 知乎 编辑:程序博客网 时间:2024/05/19 13:06
A destructor is a member that implements the actions required to destruct an
instance of a class. Destructors
cannot have parameters, they cannot have accessibility modifiers, and they
cannot be called explicitly. The
destructor for an instance is called automatically during garbage
collection.
C# LANGUAGE SPECIFICATION
40
The example
using System;
class Point
{
public double x, y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
~Point() {
Console.WriteLine("Destructed {0}", this);
}
public override string ToString() {
return string.Format("({0}, {1})", x, y);
}
}
shows a Point class with a destructor.
instance of a class. Destructors
cannot have parameters, they cannot have accessibility modifiers, and they
cannot be called explicitly. The
destructor for an instance is called automatically during garbage
collection.
C# LANGUAGE SPECIFICATION
40
The example
using System;
class Point
{
public double x, y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
~Point() {
Console.WriteLine("Destructed {0}", this);
}
public override string ToString() {
return string.Format("({0}, {1})", x, y);
}
}
shows a Point class with a destructor.
- 8.7.9 Destructors
- 17.12 Destructors
- Destructors in C#
- constructors and destructors(10.27)
- 關于Destructors
- constructors and destructors
- Constructors and Destructors in C++
- 禁止destructors引发任何异常
- Constructors and Destructors in C++
- CPP-Constructor, destructors and inheritance
- Chapter2. Constructors, Destructors, and Assignment Operators
- Item8: Prevent exceptions from leaving destructors
- Why are destructors not virtual by default?
- EC之Constructors,Destructors, and Assignment Operators
- Conclusion for Constructors,Destructors,and Assignment Operators
- Things To Remember:Constructors, Destructors, and Assignment Operators
- polymorphic base classes(多态基类)中将 destructors声明为 virtual
- 有关C++析构函数的异常(Exceptions in Destructors)
- 8.7.4 Properties
- 8.7.5 Events
- 8.7.6 Operators
- 8.7.7 Indexers
- 8.7.8 Instance constructors
- 8.7.9 Destructors
- 8.7.10 Static constructors
- 8.7.11 Inheritance
- 8.8 Structs
- 8.9 Interfaces
- 8.10 Delegates
- 简单防火墙(iptables)搭建(先写个框框,..)
- Delete不了(SQL)
- MSSQL版本[转]