text: Q:
  
  How to make class that can only be accessed through interface?
  
  In C# or Java, how can I make a class that can only be instantiate with the Interfaces it implemented on?
  Sorry if this question is asked before.
  Edit: Sorry for confusing you, and this question is just asked out of curious:
  For example I have:
  interface iA
  {
    int addNum();
  }
  
  interface iB
  {
    int minusNum();
  }
  
  class A implements iA, iB
  {
    private int A;
    public int addNum()
    {
      A += 10;
      return A;
    }
  
    public int minusNum()
    {
      A -= 10;
      return A;
    }
  }
  
  class TestIface
  {
    public static void main(String args[]) {
      A testA = new A();
      iA testiA = new A();
      iB testiB = new A();
  
      testA.minusNum(); // No error, it has access to both methods
      testA.addNum();
  
      testiA.minusNum();//ERROR
      testiA.addNum();
  
      testiB.minusNum();
      testiB.addNum();//ERROR
    }
  }
  
  I wonder if there is a way to prevent dev from just make testA and access both methods.
  
  A:
  
  How about making the constructor private?
  class A implements iA
  {
    public int returnNum()
    {
      return 10;
    }
    private A(){}
  
    public static iA getInstance(){
      return new A();
    }
  
  }
  
  A:
  
  You can make the constructor private and define a static Create method that creates new instances.
    public interface ITest
    {
    }
    public class A : ITest
    {
        private A()
        {
        }
        public static ITest Create()
        {
            return new A();
        }
    }
  
  Then the only way to create an instance of your class (besides reflection, but that's another story!) is to call the Create method like this:
  ITest test = A.Create();
  
  