Back to course

Static Members and Classes

C# Zero to Hero: Comprehensive Programming Masterclass

Static Keyword

Static members belong to the class itself rather than to a specific object instance.

Static Field

csharp class Counter { public static int count = 0; public Counter() { count++; } }

Static Class

A static class cannot be instantiated. All its members must be static (e.g., Math.PI).