Search code examples
c#staticdispose

Do I need to call Dispose() on a static object?


If I have a static WebClient object, do I need to call Dispose() on it at the end of Main()?


Solution

  • You should always Dispose() objects when you're finished with them, regardless of where you put the object.

    If the object is in a static field, it may be more difficult to figure out when you're finished with it.