2
gaben
8y

In C# I want to use 'using' on any damn temporary object I please, but it only works with objects that implement idisposable..

Comments
  • 1
    Why on every object? You only want to do that to the objects who needed to be closed after stop you using them like sqlconnections, writers, reader etc.
  • 0
    @klemenkeko in my case it's too avoid caching large objects for long periods of time when I only need them cached for three or four lines
  • 1
    Oh so you extends those classes and impement idisposable interface?
  • 0
    @klemenkeko that would definitely work.
  • 0
    @gaben

    Or you could just put them in a block...
  • 4
    Set them null if you don't neec them anymore and the GC will happily free the memory for you
    Never had to play with this kind of performance improvements in C# tho
Add Comment