Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Can we create interface protected or private if yes then how they will be implemented with a class?
Posted

1 solution

Yes.
The usual rules apply as if you were declaring a class as within an existing class:
C#
public class MyOuterClass
    {
    private void butCreate_Click(object sender, EventArgs e)
        {
        MyInterface mc = new MyClass();
        }
    public class MyClass : MyInterface
        {
        public void MyMethod()
            {
            throw new NotImplementedException();
            }
        }
    private interface MyInterface
        {
        void MyMethod();
        }
    }
The interface can be accessed by any classes defined within the outer class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900