title: C# - Make a private nested class visible through a public property
body: <p>I have the following code that does not compile:</p>
  
  <pre><code>public class Outer
    {
      public Inner MyField = new Inner(); //error here: "field type is less accessible than field"
      private class Inner
      {
          public string Message = "Hello";
      }
    }
  </code></pre>
  
  <p>I must be able to use the class like so:</p>
  
  <pre><code>var MyObject = new Outer();
  Console.WriteLine(MyObject.MyField.Message); //should output "Hello"
  </code></pre>
  
  <p>"Inner" must <em>ONLY</em> be instantiable from within "Outer", so this should <em>NOT</em> be allowed:</p>
  
  <pre><code>var MyObject = new Outer.Inner(); //I do not want users to be able to instantiate "Inner" directly
  </code></pre>