Back to course

The Static Keyword

.NET Zero to Hero: Master C# and Modern App Development

Understanding Static

static members belong to the class itself rather than to any specific object. You don't need to create an object to access static members.

Static Field:

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

Static Method:

csharp class Calculator { public static int Add(int a, int b) => a + b; }

// Accessing without object int sum = Calculator.Add(5, 10);