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:



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