考虑以下内容:
这引出了一个更重要的问题。
interface IFoo : IDisposable { }
class Program
{
static void Main()
{
var foo = GetFoo();
var anotherFoo = foo;
using(anotherFoo)
{
}
// Will the object on the heap be marked for collection?
// Or will this confuse the garbage collector
// as we are copying references?
}
}
这引出了一个更重要的问题。
Dispose()
实际上是做什么的?