Respected Sir/Madam,
Please give me correct answer with examples.
1-Why we use Private constructor in c#.
2-Why we use static constructor in c#.
3-When i'll use Private constructor in c#.
4-When i'll use static constructor in c#.
Thanks & Regards:
Sachin Sachan
Mob:9650290539
Email: [email protected]
Loading
VulpesPosted Oct 7, 2013, 3:24 AM
2. We use a static constructor to initialize static fields which can't (or can't easily) be initialized when they are declared.
3. Perhaps if you're creating a singleton i.e. a class which only has a single instance. See this link:
http://csharpindepth.com/Articles/General/Singleton.aspx
4. In the circumstances mentioned in #2 above. Suppose you're initializing a large static array using a formula for instance.
Incidentally, please don't post your email address or telephone number on a public site such as this - it's asking for trouble!