A simple nested class is not tied to any particular instance of the outer class. So, while an instance of the nested class has access to private members of the outer class, it only has access to those members that are effectively static in scope.

An instance of an inner class, by contrast, has an implicit reference back to the instance of the outer class that created it. An instance of the inner class, therefore, can reference instance members, including private ones, of that outer class instance. So, in this case, an instance of Bar has access to the count property of the Foo instance that created the Bar instance.

You can learn more about this in:
Run Edit