CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Static Field Persists Across Calls

C# code walkthrough · Question 25
hardClasses

Code

Read carefully. What does this print?
1Console.WriteLine($"{Counter.Next()} {Counter.Next()} {Counter.Next()}");
2 
3class Counter
4{
5 static int total = 0;
6 public static int Next() => ++total;
7}

Your answer