int
vs. Int32
is irrelevant to this issue. That the field is displayed as int
is just because the tool you use to look at it replaces those types by their aliases when it displays them. If you look at is with a lower level tool you'll see that it doesn't know about int
, only about Int32
.
The problem is that the Int32
struct contains an Int32
field.
"What is the int
standing on?" "You're very clever, young man, very clever," said the old lady. "But it's int
s all the way down!"
The solution to this problem is magic. The runtime knows what an Int32
is and gives it special treatment avoiding infinite recursion. You can't write a custom struct that contains itself as a field. Int32
is a built in type, no normal struct. It just appears as struct for consistency's sake.