title: Constructor vs Object Initializer Precedence in C#
body: <p>I've been learning the object initializer in C# recently, but now I'm wondering how it works when it conflicts with the constructor.</p>
  <pre><code>public class A
  {
      public bool foo { get; set; }
  
      public A()
      {
          foo = true;
      }
  
      public A(bool bar)
      {
          foo = bar;
      }
  }
  </code></pre>
  <p>What happens when I try this?</p>
  <pre><code>public class B
  {
      private A a = new A() { foo = false };
  
      private A b = new A(true) { foo = false };
  }
  </code></pre>
  <p>Is a default in the constructor a good way to have a <code>bool</code> that starts true and can be changed?</p>
  <pre><code>public A(bool bar = true)
  {
      foo = bar;
  }
  </code></pre>