T
Tony Johansson
Hello!
I have the following question:
You are creating a generic class, and you need to dispose of the generic
objects.
How can you do this?
A. Call the Object.Dispose method.
B. Implement the IDisposable interface.
C. Derive the generic class from the IDisposable class.
D. Use constraints to require the generic type to implement the IDisposable
interface.
The right answer is D but I don't fully understand why this is the right
answer.
Assume I create a generic class called Farm. This Farm can contain Animals
like this.
public class Farm<Animals>
{
....
}
Now to my question if this generic class Farm<Animals> implement
IDisposable
then method Dispose can be called to dispose of the generic objects.
I mean if I want to dispose all of the Animals object I can just call the
dispose method located in
the farm class but if I call the dispose method in the Animal class
the Farm object is still there.
Can anybody make a comment about my discussion.
//Tony
I have the following question:
You are creating a generic class, and you need to dispose of the generic
objects.
How can you do this?
A. Call the Object.Dispose method.
B. Implement the IDisposable interface.
C. Derive the generic class from the IDisposable class.
D. Use constraints to require the generic type to implement the IDisposable
interface.
The right answer is D but I don't fully understand why this is the right
answer.
Assume I create a generic class called Farm. This Farm can contain Animals
like this.
public class Farm<Animals>
{
....
}
Now to my question if this generic class Farm<Animals> implement
IDisposable
then method Dispose can be called to dispose of the generic objects.
I mean if I want to dispose all of the Animals object I can just call the
dispose method located in
the farm class but if I call the dispose method in the Animal class
the Farm object is still there.
Can anybody make a comment about my discussion.
//Tony