- class A
- {
- ~A()
- {
- code;
- }
- }
- using System;
- using System.Text;
- namespace forgetCode
- {
- class A
- {
- ~A()
- {
- Console.WriteLine("Destruct instance of A");
- }
- }
- class B
- {
- object Ref;
- public B(object o)
- {
- Ref = o;
- }
- ~B()
- {
- Console.WriteLine("Destruct instance of B");
- }
- }
- class program
- {
- public static void Main()
- {
- B b = new B(new A());
- b = null;
- GC.Collect();
- GC.WaitForPendingFinalizers();
- }
- }
- }