public class Path : IEnumerable<Point3D>
{
private List<Point3D> points = new List<Point3D>();
public IEnumerator<Point3D> GetEnumerator() => points.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => points.GetEnumerator();
public void Add(Point3D pt) => points.Add(pt);
}
public static class Extensions
{
public static void Add(this Path path, double x, double y, double z) => path.Add(new Point3D(x, y, z));
}
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The new object initialization syntax works fine for me.

That is not the code I posted.
@bunda3d, My fault.
I think the example you're referring to misses the following using statements:
using System.Collections;
using System.Collections.Generic;
and misses a Point3D declaration which could be like this:
public class Point3D
{
private double _x;
private double _y;
private double _z;
public Point3D(double x, double y, double z)
{
_x = x;
_y = y;
_z = z;
}
}
You may need to wait for @BillWagner to review this. I also think that it will be better to add an entry point (Main method) to the example for further illustration.
I was thinking it needed "using" statements, but that doesn't usually need to be considered in the "focus mode" editor, for whatever reasons.
Thanks for writing this @bunda3d
The problem is due to an issue in the underlying try.net experience used on docs. An update will get deployed this month, and that will enable us to fix this.
I've added this to the list of planned work for this sprint.
/cc @LadyNaggaga @aprilspeight
Closing as duplicate of #20753
Most helpful comment
Thanks for writing this @bunda3d
The problem is due to an issue in the underlying try.net experience used on docs. An update will get deployed this month, and that will enable us to fix this.
I've added this to the list of planned work for this sprint.
/cc @LadyNaggaga @aprilspeight