CodeJoy CodeJoy - 6 months ago 60
C# Question

Private Nested class

I was following a tutorial about nested classes
But for me, it gives an inconsistent accessibility exception

Why does this work for him ?

Tutorial video

class Employee
private class Manager

public Manager man = new Manager();


You cannot have man declared as public when Manager is declared private. A caller from the outside could see man but not Manager, so man would be of no use to him.

Either make man private or Manager public.