CJCoding With Joseph
← Back to Question List
C# Code Walkthrough #25

Static Field Persists Across Calls

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