title: Create factory pattern
body: <p>I'm trying to use the factory pattern and have created three interfaces.</p>
  
  <p><strong>ITest1</strong></p>
  
  <pre><code>public interface ITest1: ITestX
  {
      void Write(string name);
  }
  </code></pre>
  
  <p><strong>ITest2</strong></p>
  
  <pre><code>public interface ITest2: ITestX
  {
      void Read(string name);
  }
  </code></pre>
  
  <p>and <strong>ITestX</strong></p>
  
  <pre><code>public interface ITestX
  {
  
  }
  </code></pre>
  
  <p>The interfaces ITest1 and ITest1 are implemented in classes A and B:</p>
  
  <pre><code>public class A: ITest1 
  {
      public void Write(string name)
      {
          Console.WriteLine(name);
      }
  }
  
  public class B: ITest2
  {
      public void Read(string name)
      {
          Console.WriteLine(name);
      }
  }
  </code></pre>
  
  <p>As for the <strong>factory</strong>, my interface looks like this:</p>
  
  <pre><code>public interface IFactory
  {
      ITestX GetClass(ClassType cType);
      ITestX GetClass(int cType);
  }
  </code></pre>
  
  <p>The class <strong>ClassType</strong>:</p>
  
  <pre><code>public class ClassT
  {
      public int Type { get; set; }
  
      public static class ClassType
      {
          public const int AType = 0;
          public const int BType = 1;
      }
  }
  </code></pre>
  
  <p>The Factory class which implements the factory interface:</p>
  
  <pre><code>public class Factory : IFactory
      {
          public ITestX GetClass(ClassType cType)
          {
              return GetNetwork(networkType.Type);
          }
  
          public ITestX GetClass(int cType)
          {
              switch (cType)
              {
                  case ClassT.ClassType.AType:
                      return new A();
                  case ClassT.ClassType.BType:
                      return new B();
                  default:
                      throw new NotImplementedException();
              }
          }
  }
  </code></pre>
  
  <p>In my test method, I try to use the factory:</p>
  
  <pre><code>Factory factory = new Factory();
  var typeClass = factory.GetClass(new ClassT{ Type = ClassT.ClassType.AType }); 
  </code></pre>
  
  <p>However, I can't use the <code>Read</code> or <code>Write</code> methods because they are not visible in <code>typeClass</code>. What's going on? Why can't I access them?</p>