If you put this code inside a test class... and set two breakpoints at the arrange and assert calls, you will be able to use the diagnotics window in VS2022 to inspect the details
Microsoft documentation for VS2022
struct ExampleStruct
{
public int ID;
public List<ExampleStruct> children;
}
public class StackOverflowStructQ
{
[Fact]
public void Method_Condition_Expectation()
{
// Arrange
ExampleStruct es = new() { ID = 1, children = [] };
// Act
// Assert
Assert.NotNull(es.children);
}
}
The when the first breakpoint is hit - "take a snapshot" from the Diagnostics window.
You should be able to drill down and see "Referenced Objects". This means the reference is stored in the struct, but the object it references is stored on the heap.
So try and keep your structs lightweight. If you need to reference objects which will ultimately reside on the heap, probably best to use a class?