C#C
C#2y ago
goated

I'm confused what IDisposable is used for

So I was expecting once the code run out of the using {} the class would be destroyed (and if we try to access it will throw a null ref exception)therefore helping the system, but it turns out if I keep a reference to it it wouldn't be destroyed, which means it's going to check is there any reference to the object anyways, it's not going to optimize the code right? Using a normal class and disposable feels the same
Was this page helpful?