C# Compiler Error
CS0106 – The modifier ‘modifier’ is not valid for this item
Reason for the Error
You will receive this error when you have marked your class or interface with an invalid access modifier.
Take the below code snippet as an example.
abstract interface ITest { public void M(); } public class DeveloperPublish { public static void Main() { } }
You have an interface by the name ITest and you have prefixed it with the abstract keyword in the explicit interface declaration.
This will result in the CS0106 error.
Solution
To fix the above error, remove the abstract keyword from the explicit interface declaration.
There are plenty of other scenarios where you would encounter a similar scenario. For example, in the C# versions before C# 8.0 and when you have the public keyword defined on the explicit interface declaration, you will receive the same error.