Inconsistent accessibility strange error
<p>I have this below piece of code which makes me puzzling about internals of a private class. I could see many search results for this error, still the below sounds wierd</p>

<pre><code>namespace X
{
    public class Program
    {
        public static XYZ sample1;
        public static void Main(string[] args)
        {
            XYZ sample2 = new XYZ(); // OK  (1)
            sample1 = new XYZ();  // NOK    (2)
                    ...
        }
    }

    private class XYZ
    {

    }
}
</code></pre>

<p>If class XYZ is private, how does it work at (1) but not in (2)?</p>
