Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3486902
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:05:11+00:00 2026-05-18T11:05:11+00:00

I try to avoid using static classes in my production code as they cant

  • 0

I try to avoid using static classes in my production code as they cant be injected, there is no control over default initialization and lastly you can’t really clean up your resources implicitly as there is no destructor for static objects. Additionaly, you cannot implement the IDisposable for a static class as well, so sounds like static classes are never good for being a wrapper around unmanaged resources…
It totally seems like singletons are a better solution to replace the use of static classes directly in that case. But my question is – why doesn’t the compiler support static destruction, after all what difference does it make for the GC to keep track of references to a static object vs an instance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:05:12+00:00Added an answer on May 18, 2026 at 11:05 am

    There’s no such thing as a “static object”. But all static variables in all types loaded in any app domain are treated as GC roots until the app domain is unloaded.

    If you want to do things when the app domain is unloaded, you could subscribe to AppDomain.DomainUnload and AppDomain.ProcessExit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading this: Guideline Number 7: Try to avoid using unecessary classes and
I always try to avoid to return string literals, because I fear they aren't
We try to convert from string to Byte[] using the following Java code: String
Possible Duplicate: How to access java-classes in the default-package? I am using Eclipse 3.5
I normally try to avoid duplication and adhere to the DRY principle. However, I'm
I know that cursors are frowned upon and I try to avoid their use
I try to add an addons system to my Windows.Net application using Reflection; but
Is there any way to make static libraries built in Microsoft Visual Studio independent
Is there a way to test if a collection is already initialized? try-catch only?
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.