Class is inaccessible due to its protection level

Cause

As it already states that class is inaccessible due to its protection level, it means that the protection level of the constructor or class is not public due to which it cannot be accessed by any other class. Therefore, you need to make it public so it can be accessed by other classes.

Sometimes the class is public but the constructor is not due to which it is still inaccessible. So, ensure that both are public so your issue may get resolved.

Solution

Make the problematic class public e.g.

public class Teacher

instead of

class Teacher

One thought on “Class is inaccessible due to its protection level

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

Create your website at WordPress.com
Get started
%d bloggers like this: