CodeJoy CodeJoy - 1 year ago 125
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();

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download