private means the type is defined for the scope. if a class define a private class, only that class can reference the type.
for a class to have an interface, it must inherit and implement a defined interface. the interface could be public, even if the class is private,
sample:
using System;
public class Program
{
public static void Main()
{
var foo = new Foo();
foo.Bar.Echo("hello"); //works
//foo.Bar.Echo2("hello"); //compile error - undefined
}
public interface IBar
{
void Echo(string s);
}
public class Foo
{
public readonly IBar Bar;
public Foo()
{
Bar = new _Bar();
// cast object to private class to call class method
((_Bar) Bar).Echo2("Foo Created");
}
private class _Bar : IBar
{
// interface method
public void Echo(string s) { Console.WriteLine(s); }
// class only method
public void Echo2(string s) { Console.WriteLine(s); }
}
}
}