CodeJoy CodeJoy - 4 months ago 44
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.