Recently i received this interesting question, suppose, if i implement an Custom interface with a dispose() method, will Garbage Collector detect?
No. Garbage Collector will not detect custom interface. We should implement IDisposable interface and needs to implement dispose() method. Then only Garbage Collector consider the object for cleaning memory.
Internally GC could have performed this check for only types which implemented interface "IDisposable". Another reason behind this is, implementing such kind of patterns will leads to another problems, like suppose, a developer unknowingly keep the method name as "Dispose" itself. So, to avoid these problems, GC will check for types which implements the interface "IDisposable" only
ASP.NET Interview questions · · · ·