0

I was experimenting with an alternative for the friend keyword in c#. (Based on Why does C# not provide the C++ style 'friend' keyword?). Resulting with this code:

public class ParentClass
{
    private interface IChild
    {
        void Fn();
    }
    public class Child : IChild
    {
        void IChild.Fn() { }
    }    
}

The Method Fncan only be accessed by the ParentClass and the Child. (As Expected)

My Question:

What Accessibility Level has Fn? public, private, protected, internal, private internal and protected internal gave all errors.

  • 1
    [_"An explicit interface implementation **doesn't have an access modifier** since it isn't accessible as a member of the type it's defined in"_](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/explicit-interface-implementation) – CodeCaster Oct 30 '22 at 18:07

0 Answers0