C# Error CS0107 – More than one protection modifier

C# Compiler Error

CS0107 – More than one protection modifier

Reason for the Error

In C#, you are allowed to have only one access modifier on a class member. However, there is an expected when you use protected internal and private protected. Apart from these 2 access modifiers you cannot have more than one access modifiers for a class member.

You will receive this error when you marked your class with multiple access modifiers.

Try compiling the below code snippet and you will receive the CS0107 error.

public class Class1
{
    private internal void Method1()  
    {
    }
}

public class DeveloperPublish
{
    public static void Main()
    {

    }
}
C# Error CS0107 – More than one protection modifier

Solution

To fix the above error, remove the multiple access modifier and ensure that only one access modifier is used.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...