Static Classes

suggest change

The “static” keyword when referring to a class has three effects:

  1. You cannot create an instance of a static class (this even removes the default constructor)
  2. All properties and methods in the class must be static as well.
  3. A static class is a sealed class, meaning it cannot be inherited.
public static class Foo
{
```
//Notice there is no constructor as this cannot be an instance
public static int Counter { get; set; }
public static int GetCount()
{
    return Counter;
}
```
}

public class Program 
{
```
static void Main(string[] args)
{
    Foo.Counter++;
    Console.WriteLine(Foo.GetCount()); //this will print 1
    
    //var foo1 = new Foo(); 
    //this line would break the code as the Foo class does not have a constructor
}
```
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Static Classes:
* Static Classes

Table Of Contents
17 Regex
19 Arrays
21 Enum
22 Tuples
24 GUID
27 Looping
36 Casting
41 Static Classes
46 Methods
88 Events
92 Structs
104 Indexer
106 Stream
107 Timers
109 Threading
127 Caching
135 Pointers
147 C# Script