You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Static classes and static members offer a mechanism to use class as a container that has no internal state. This makes it a convenient choice for implementing a set of pure functions.
Following constraints are placed on a static class:
all members must be static
can't be instantiated
can't be used as a base class
can't contain a constructor
staticclassMath{Math(){// <-- throws an error, cannot }functionfoo(){// <-- throws an error, all members of a static class must be static}}newMath()// <-- throws an error, static class can't be instantiatedclassMath2 : Math{// <-- throws an error, static class is sealed}