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

Static Field Shared Across Instances

C# code walkthrough · Question 47
hardClasses

Code

Read carefully. What does this print?
1new Widget();
2new Widget();
3new Widget();
4Console.WriteLine(Widget.Total);
5 
6class Widget
7{
8 public static int Total = 0;
9 public Widget() => Total++;
10}

Your answer