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 9292475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:53:20+00:00 2026-06-18T20:53:20+00:00

I am aware that, static constructors always take precedence and get called first before

  • 0

I am aware that, static constructors always take precedence and get called first before any instance constructors. However consider the scenario of me having one instance class and one static class. I am wondering why the results are first from Base class and then static class ? I have also verified interchanging calling, I get the result accordingly. But am I wrong in my thoughts that, Static classes always should be called first irrespective of any other instance classes ? Why this raised to me is because, I saw somewhere that, Static classes are loaded automatically when the namespace containing that class is triggered. Then I would expect that static constructor to fire first. Why not it is happening ? Could someone please explain in an understandable and simple way.

    public class Base
    {
        public Base() { Console.WriteLine(" I am from normal Base constructor"); }
        static Base() { Console.WriteLine("Hey I am from Static Base"); } 
    }
    public static class Base1
    {
        static Base1() { Console.WriteLine("I am from Static Constructor"); }
        public static void StaticMethod() { Console.WriteLine("I am from Static Method");   }            
    }

    static void Main(string[] args)
    {
        Base b = new Base();
        Base1.StaticMethod();
        Console.Read();
    }
  • 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-06-18T20:53:21+00:00Added an answer on June 18, 2026 at 8:53 pm

    Static constructors are only called if they are actually needed. If they are needed, they are guaranteed to be called before the normal constructors for their class.

    But there is no guarantee that all static constructors will be called before any normal constructor for a different class.

    It wouldn’t be possible to do that AND avoid calling static constructors that aren’t used. You could do something like only access a class with a static constructor just before the program terminates, and then only if some condition was satisfied. Clearly, the code couldn’t peer ahead in time to determine whether or not the static constructor call would be needed; therefore, there is no way for it to call the static constructor before your code accesses it.

    Check out Eric Lippert’s Blog about Static Constructors for many more details!

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

Sidebar

Related Questions

I aware that Java object constructors implicitly initialize their instance's non-static fields. However, I'm
I'm aware that sleep should be accessed in a static context. However I need
I am aware that MD5 hashes are not advisable for security any more but
When a static method is called, is there any way for it to know
Are class that are declared inside and interface automatically declared static? I am aware
I'm aware that I cannot have new ReflectionClass(static) in PHP (5.3) as I just
First of all; I'm aware that this question is strange and I will probably
I aware that this will be a less programming question, but still... How can
I am aware that I can set null like string val = null; But
I'm aware that this is possible with the os module's os.system(color) function, but this

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.