title: Cannot access non-static field [fieldname] in static contex
body: <p><strong>The Base Class:</strong></p>
  
  <pre><code>public class DatabaseBase
  {
    private readonly string connectionString;
    private bool useCounters;
  
    public DatabaseBase(string connectionString)
    {
     this.connectionString = connectionString;
    }
  
    public DatabaseBase(...)
    {
     connectionString = ...;   
    }
  
    public DatabaseBase(..)
    {
     connectionString = string.Format(...);
    }
  
    public string ConnectionString
    {
     get { return this.connectionString; }
    }
  
  ...
  </code></pre>
  
  <p><strong>The derived class:</strong></p>
  
  <pre><code>public class ProjectDB : DatabaseBase
  {
  private bool useServiceConnection;
  
   private static string ConnectionString
   {
       get
       {
          string connectionString = useServiceConnection == true ? ConfigurationManager.AppSettings["SomeConnection1"] : ConfigurationManager.AppSettings["SomeConnection2"];
           return connectionString;
       }
   }
  
  
  public ProjectDB() : this(false)
  {
  }
  
   private bool isServiceCall;
  
  public ProjectDB(bool useServiceConnection)
      : base(ConnectionString)
  {
      this.useServiceConnection = useServiceConnection;
  }
  
  private SqlConnection CreateConnection()
  {
      return new SqlConnection(ConnectionString);
  }
  </code></pre>
  
  <p>I'm getting the error "Cannot access non-static field useServiceConnection in static context" for this line:</p>
  
  <pre><code>string connectionString = useServiceConnection == true ? ConfigurationManager.AppSettings["SomeConnection1"] : ConfigurationManager.AppSettings["SomeConnection2"];
  </code></pre>
  
  <p>However if I make useServiceConnection a static var to satisfy the quirement, then I get that same error here in the constructor:</p>
  
  <pre><code>public ProjectDB(bool useServiceConnection)
      : base(ConnectionString)
  {
      this.useServiceConnection = useServiceConnection;
  }
  </code></pre>
  
  <p>Now if I make useServiceConnection and ConnectionSting property non-static, then I get that error for the constructor here:</p>
  
  <pre><code>public LitleDB(bool useWebServiceConnection)
      : base(ConnectionString)
  {
      this.useWebServiceConnection = useWebServiceConnection;
  }
  </code></pre>
  
  <p>I think the first 2 I understand.  </p>
  
  <p>But now with the example updated below, why would the constructor in this case give me an error still?  Those are no longer static so where's the static context being expected from?  So here's what I have now:</p>
  
  <pre><code>public class ProjectDB : DatabaseBase
   {
      private bool useServiceConnection; &lt;-- NO LONGER STATIC
  
       private new string ConnectionString &lt;-- NO LONGER STATIC
       {
           get
           {
              string connectionString = useServiceConnection == true ? ConfigurationManager.AppSettings["SomeConnection1"] : ConfigurationManager.AppSettings["SomeConnection2"];
               return connectionString;
           }
       }
  
      public ProjectDB() : this(false)
      {
      }
  
       private bool isServiceCall;
  
      public ProjectDB(bool useServiceConnection)
          : base(ConnectionString)  &lt;--- IT'S COMPLAINING HERE NOW, SO WHERE IS IT TRYING TO ACCESS STATICALLY?  I DON'T GET WHY
      {
          this.useServiceConnection = useServiceConnection;
      }
  </code></pre>
  
  <p>I have other static properties in this class, does that have anything to do with it?  I'm not using them though.</p>