Static Functions and Namespaces

Learn how to use static functions and properties in classes to have a single instance of a function or property throughout the code base.

Static functions

A class can mark a function with the static keyword, meaning that there will only be a single instance of this function available throughout the code base.

When using a static function, we do not need to create an instance of the class in order to invoke this function, as follows:

Get hands-on with 1400+ tech skills courses.