static class vs. static struct

vyarthrot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Nov 19 22:15:11 PST 2015


On Monday, 26 January 2015 at 14:02:54 UTC, ref2401 wrote:
> What's the difference between static class and static struct?
> What should i use?

In simple words, Singleton is a pattern and not a keyword. The 
Singleton pattern has several advantages over static classes. A 
singleton allows a class for which there is just one, persistent 
instance across the lifetime of an application. That means, it 
created a single instance and that instance (reference to that 
instance) can be passed as a parameter to other methods, and 
treated as a normal object. While a static class allows only 
static methods and and you cannot pass static class as parameter.

Full Source:

http://net-informations.com/faq/netfaq/singlestatic.htm

Vyar



More information about the Digitalmars-d-learn mailing list