Thursday, September 06, 2012

Difference between Static Constructor and Private Constructor

Posted by Rahul Kharde at 4:53 AM

Static Constructor
Private Constructor
The static constructor will only be executed once.
The private constructor will be executed each time it is called.
The static constructor cannot have parameters.
The private Constructor may have parameters
A static constructor is called before the first instance is created. So it’s kind of global initialize.
Private constructor is called after the instance of the class is created. Inheritance-wise both are same.
A class can have only one static constructor
A class can have multiple private constructors
public static class Class1
   static Class1()
public class Class2
    private Class2()

If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!

Kindly Bookmark and Share it:



Jagna Co Kalani on November 3, 2017 at 6:43 AM said...

This is an amazing blog,it gives very helpful messages to us.Besides that Wisen has established as Best Dot Net Training in Chennai. or learn thru ASP.NET Online Training . Nowadays Dot Net has tons of job opportunities on various vertical industry.

mounika on July 11, 2018 at 5:45 AM said...

It 's an amazing article and useful for developers
.Net Online Course

Have any question? Feel Free To Post Below:


Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top