title: Using nameof of non-static field in static field initializer
body: <p>I have a class with a static <code>List&lt;T&gt;</code> and some non-static fields. Now I'd like to initialize this list with some objects like so:</p>
  
  <pre><code>class C
  {
      private Bar bar;
  
      private static List&lt;Foo&gt; list = new List&lt;Foo&gt;()
      {
          new Foo(nameof(bar)),                    // OK
          new Foo(nameof(bar) + nameof(bar.Baz))   // Error CS0236
      };
  }
  </code></pre>
  
  <p>While creating the first <code>Foo</code> object works fine, I'm getting the error</p>
  
  <blockquote>
    <p>A field initializer cannot reference the non-static field, method, or
    property C.bar</p>
  </blockquote>
  
  <p>on the second.</p>
  
  <p>I'm aware that static members can't access instance data (see <a href="https://stackoverflow.com/questions/27725571">this question</a>). But as far as I understand, <code>nameof</code> is evaluated at compile time and accesses only metadata and not instance data. So why doesn't this work and is there a way around?</p>