title: Accessing protected members of another class
body: <p>I have one class A, from which I need to access protected members of class B, in the same manner that one would use the friend keyword in C++. However, the internal modifier does not suit my needs. Class B will need to create an instance of class A, modify its private data, and return a reference to that class. Those class A members will need to remain private to the original caller.</p>
  
  <pre><code>public class A
  {
      protected int x;
  }
  
  public class B
  {
      public static A CreateClassA()
      {
          A x = new A();
          x.x = 5;   // ERROR : No privilege
          return x;
      }
  }
  </code></pre>