Follow

What is CS0122?

Symptoms

When trying to enter play mode, I am receiving the error below:

error CS0122: `___' is inaccessible due to it's protection level public

Cause

The CS0122 error is caused when a member without the public access modifier applied is invoked from another script.

In this example we have created a private method and attempted to invoke it after checking the value of a private variable.

Here is how the errors appear in this example:

error CS0122: `PrivateMethodScripts.dragonsSpawned' is inaccessible due 
to its protection level

error CS0122: `PrivateMethodScripts.SpawnDragons()' is inaccessible due
to it's protection level

Resolution

The error CS0122 is resolved by changing the member's access modifier to public.

More Information

https://msdn.microsoft.com/en-us/library/ha94aebs.aspx

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.