For example:
public class A : A.B { public class B { } }
Which generates this error from the compiler:
Circular base class dependency involving ‘A’ and ‘A.B’
I always figured a nested class behaved just like a regular class except with special rules concerning accessing the outer class’s private members, but I guess there’s some implicit inheritance occurring between the two classes?
There’s no implicit inheritance involved as far as I can tell. I would have expected this to be okay – although I can imagine weirdness if A and B were generic.
It’s specified in section 10.1.4 of the spec:
I’ve highlighted the relevant section.
That explains why the compiler is rejecting it, but not why the language prohibits it. I wonder if there’s a CLI restriction…
EDIT: Okay, I’ve had a response from Eric Lippert. Basically, it would be technically possible (there’s nothing in the CLI to prohibit it), but:
It was also noted on the email thread that it would make this kind of thing valid:
… but that would already (as noted by Tinister) be valid if B derived from A.
Nesting + inheritance = oddness…