1

In what situations do I initialize a class using a static constructor?

2 Answers 2

4

From here:

A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. It is called automatically before the first instance is created or any static members are referenced.

Sign up to request clarification or add additional context in comments.

Comments

0

When your class uses some static members that need to be initialized or when you want to ensure that some initialization code specific to this class is guaranteed to be executed only once for the entire lifetime of the AppDomain.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.