G
Guest
Hi!
I'd like to free-up - destroy (myself not GC) object n (Node) with implementing Dispose().
I have linked list:
class Node{
CNode nextNode;
object data;
public Node(object d)
{
data = d;
}
~Node(){}
public void Dispose()
{
Console.WriteLine("Destoyed");
GC.SuppressFinalize(this);
}
}
class Test{
public static void Main(){
Node n = new Node();
n.Dispose();
}
}
If I understood text on msdn.com method GC.SuppressFinalize(this) just requests that the system not call the finalizer method for the specified object. So, what should I do/add to Dispose() method that it will explicit free (destroy) class Node? Or that code succesfuly destroys object n?
btw: I've already tried explicitly call Finalize(), but i got an error.
thanks,
Dejan
I'd like to free-up - destroy (myself not GC) object n (Node) with implementing Dispose().
I have linked list:
class Node{
CNode nextNode;
object data;
public Node(object d)
{
data = d;
}
~Node(){}
public void Dispose()
{
Console.WriteLine("Destoyed");
GC.SuppressFinalize(this);
}
}
class Test{
public static void Main(){
Node n = new Node();
n.Dispose();
}
}
If I understood text on msdn.com method GC.SuppressFinalize(this) just requests that the system not call the finalizer method for the specified object. So, what should I do/add to Dispose() method that it will explicit free (destroy) class Node? Or that code succesfuly destroys object n?
btw: I've already tried explicitly call Finalize(), but i got an error.
thanks,
Dejan