using System;
public class Program
{
public class Box
private readonly Box insideBox;
public Box (Box box = null)
insideBox = box;
}
public int NumberOfInsideBoxes
get
if (insideBox != null)
return 1 + insideBox.NumberOfInsideBoxes;
return 0;
public static void Main()
Console.WriteLine(new Box(new Box(new Box())).NumberOfInsideBoxes); // 2