C# Static Class


This entry is part 7 of 8 in the series C# Classes Intermediate

A static class is a class where all the members are static. Static classes are used to group data and functions that are not affected by instance data. You might want to use a static class to contain some math functions and data that are available throughout your program.

You access the members of a static class just as you would access any static member—by using the class name and the member name. Also, starting with C# 6.0 you can access members of a static class without the class name provided that you have a using static directive.

  • The class itself must be marked static.
  • All the members of the class must be marked static.
  • The class can have a static constructor, but it cannot have an instance constructor since you cannot create an instance of a static class.
  • Static classes are implicitly sealed. That is, you cannot inherit from a static class.
Series Navigation<< C# ConstantsC# Sealed Class >>