C# Static Members
static members belong to the class, not to objects. Use them for helpers and shared counters. Extension methods add methods to existing types.
Example
class Counter { public static int Total; public static int Next() => ++Total; }
Console.WriteLine(Counter.Next() + " " + Counter.Next());
static class Ext { public static bool IsEven(this int n) => n % 2 == 0; }
Console.WriteLine(4.IsEven());Exercise
Belongs to the class.
public int Count;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.